Tagged: Core Java

String methods - matches and regionMatches

String methods – matches and regionMatches

In this post, we will discuss about the String methods – matches and regionMatches. boolean matches(String regex): It returns true if String matches the given regular expression. regex – the regular expression to which...

String methods - split

String methods – split()

In this post, we will discuss about the string methods – Split(). This method is used to split the string on the basis of given regular expression in arguments. It will return a String...

isempty and lastindexof

String methods – isEmpty() and lastIndexof

In this post, we will discuss about 2 methods which are isEmpty and lastIndexOf. Let’s understand them with examples. boolean isEmpty(): Returns true , if length of the string is 0. public class StringMethodsEx...

getbytes

String methods – getBytes() and getChars()

In this post, we will discuss about String methods – getBytes() and getChars().Let’s look at them one by one with examples. getbytes(): Encodes this String into a sequence of bytes using the platform’s default charset,...

contentequals

String methods – contentEquals

ContentEquals() is used to compare the string. It has 2 types of implementations. boolean contentEquals(CharSequence cs) boolean contentEquals(StringBuffer sb) Let’s understand them with the help of examples. boolean contentEquals(CharSequence cs): Returns true if string...

startswith and endswith

String methods – startsWith and endsWith

In this post, we will discuss 2 methods which are endsWith() and startsWith(). Let’s understand with examples. boolean endsWith(String suffix): This method checks if string ends with specified suffix. If ends with specified  suffix then returns...

concat and contains

String methods – Concat and contains

In this post, we will see 2 string methods which are  concat and contains. String concat(String str): The method appends a specified string to the end of this string. If the length of the string...

substring

String methods – substring

As its name says, it is used to get the substring from the any String. It has 2 types of implementations. String substring(int beginIndex) String substring(int beginIndex, int endIndex) Let’s look at them one...

Call by value

Call by value in java

In java, we have only ‘Call by value’, not ‘Call by reference’. In ‘Call by reference’ the address of the value is passed in the arguments of the methods, so if any changes made...

Encapsulation in java

Encapsulation in java

Encapsulation is one of the four fundamental OOP concepts. Remaining three are inheritance, polymorphism, and abstraction.In the previous post, we have studied the Abstract class and interface. In this post, we will focus on encapsulation....