Java String Methods PDF
Java String Methods PDF
int hashCode()
It returns the hash code of the string.
boolean contains(CharSequence s)
It checks whether the string contains the specified sequence of char values. If yes
then it returns true else false. It throws NullPointerException of ‘s’ is null.
3 Java String Methods
String toUpperCase()
Equivalent to toUpperCase(Locale.getDefault()).
String toLowerCase()
Equivalent to toLowerCase(Locale. getDefault()).
String trim()
Returns the substring after omitting leading and trailing white spaces from the
original string.
char[] toCharArray()
Converts the string to a character array.
byte[] getBytes()
This method is similar to the above method it just uses the default charset
encoding for converting the string into sequence of bytes.
int length()
It returns the length of a String.