JAVA
JAVA
Usage- This function returns the length of characters present in the string.
2. charAt();
Syntax- char charAt(int n);
3. toUpperCase();
Syntax- String toUpperCase();
Usage- This function/method is to convert all the character of the string into
uppercase.
4. toLowerCase();
Syntax- String toLowerCase();
Usage- This function/method is to convert all the characters of the string into
lowercase.
5. replace();
Syntax- String replace(char ch1,char ch2);
Usage- This function replaces all the occurrances of the character ch1 with ch2 in the
string.
6. trim();
Syntax- String trim();
Usage- This function is used to remove all the white spaces at the beginning and end
of the string .
7. equals();
Syntax- boolean equals(String2);
Example-s1.equals(s2);
8. concat():
Syntax- String concat(String2);
Example-s1.concat(String s2);
9. substring();
Syntax- String substring(int n);
Usage-This function returns substring starting from the nth character of the string.
Usage-This function returns substring starting from mth character upto the nth
character without including the nth character.
11. indexOf();
Syntax for string- int indexof(String str);
Usage-This returns the position of the first occurrence of the character or string in the
string.
int indexOf(‘y’,n);
This format gives the position of ”the” and ‘y’ starting from the nth position in String.
13. compareTo();
Syntax- int compareTo(string str);
Example-s.compareTo(s1);
Usage- Tests if the this string (current Stringobject)ends with the specified suffix
(str).
15.int lastIndexOf(char ch)
Usage-returns the index within the this string of the last occurrence of the specified
character.