Category: Java

Different ways to reverse the string

Different ways to reverse String in java

There can be different ways to reverse the String. Here , we are mentioning few. Let’s understand them with example. 1. We can reverse the string by using a for loop and method charAt....

StringBuilder in java

StringBuilder in java

StringBuilder in java is like a String ,but which can be modified. It is same as StringBuffer, but only difference is that it is non-synchronized. The length of the String and content of sequence can...

StringBuffer class in java

StringBuffer class in java

StringBuffer class in java is like a String ,but which can be modified. The length of the String and content of sequence can be changed by using StringBuffer methods. It can be implemented in following...

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...

replace

String methods – replace

In this post, we will discuss about replace(),replaceFirst() and replaceAll. As it name says , method replace is used to replace a sequence of characters in a string with a expected characters or substring....

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...

tostring,touppercase

String methods – toString,toUppercase,toLowercase,toChararray

In this post, we will discuss about the string methods toString,toUppercase,toLowercase,toChararray. Let’s see them one by one with examples. String toString(): This method returns itself i.e. a same string. public class StringMethodsEx { public static...

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...