Tagged: Java

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

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

String methods in java

String methods in Java

There are numerous string methods in java which are helpful for performing different and useful operations on Strings. Here is the table containing all the methods present in Strings. You can click on the methods name...

String in java

String in java

String is nothing but a sequence of characters. For example, “Book” is a string which is having sequence of 4 characters. There is a lot of importance of String and its usage in any programming language. In...