indexOf() ,length() and trim()

Let us understand IndexOf(), length() and trim() indexOf() method This method returns the index of first occurrence of a substring or a character or -1 if the character does not occur. indexOf() method has 4 different overloaded forms int indexOf(int ch) It returns the index of the first occurrence of the specified character within this […]

Share this article on

String charAt()

Let us understand charAt() method This method returns the character at the specified index and Index starts from 0 Method signature public char charAt(int index) public char charAt(int index) This method throws StringIndexOutOfBoundsException exception When, index is either negative or greater than or equal to the size of the string Example public class CharAtExample1{   […]

Share this article on
< Previous Next >