String replace

We have replace() method in java which returns a new string by replacing all the characters or CharSequences with a specified new character or CharSequence. There are 4 methods for replacing a string or char value public String replace(char oldChar, char newChar) public String replace(CharSequence target,CharSequence replacement) Public String replaceAll(String regex, String replacement) Public String […]

Share this article on

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
< Previous Next >