String class functions
The following are the most commonly used functions of the String class:
The charAt() function
The following line of code is an example of the charAt() function in a Java program:
public char charAt(int index)
The charAt() function returns the char value at the specified index. An index ranges from 0 to length() - 1. The first char value of the sequence is at index 0, the next at index 1, and so on, as for array indexing. The following is another example:
String str = "welcome"; System.out.println(str.charAt(2));
The output is displayed here:
l
The equalsIgnoreCase() function
The following line of code is an example of the equalsIgnoreCase() function in a Java program. It compares one String to another String, ignoring case considerations. Two strings are considered equal ignoring case if they are of the same length, and corresponding characters in the two strings are equal ignoring case.
String str = "java"; System.out.println(str.equalsIgnoreCase("...