Author: Shekhar Sharma

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

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

charat and compareto

String methods – charAt() and compareTo()

I this post, we will discuss about string methods charAt() and compareTo(). Let’s discuss them one by one with examples. charAt(): The method charAt(int index) returns the character at the specified index. Index should...

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

trim and length

String methods – trim() and length()

I this post, we will discuss about the string methods – trim() and length(). Let’s understand them one by one with examples. trim(): The method trim() is used to remove leading and trailing white...

String method - indexof

String method- indexof

indexof method is used to find out the index of a particular character or Substring into the String. It has 4 type of different signatures. int indexOf(int ch) int indexOf(String str) int indexOf(int ch,int...

equals and equalignorecase

String methods – equals() and equalsIgnoreCase()

These methods are used to compare 2 string objects. If both String matches, returns true else false. Equals(): Equals is used to compare 2 strings and it is case sensitive. e.g. The Strings “JAVA” and...