Java String Methods:
We can use the Eclipse IDE for this example. If you do not know about it then follow this link- How to Install Eclipse For Java and create a program in it. |
The String class contains many useful methods for string processing applications. Some Java String Methods are given below.
(1) equals()– Compares two strings. Returns true if the strings are equal, and false if not.

(2) equalsIgnoreCase()– Compares this string to another String ignoring case considerations.

(3) charAt()– Returns the character at the specified index.

(4) length()– Returns the length of characters present in the string.

(5) indexOf()– It returns the specified char value index.

(6) isEmpty()– It checks if a string is empty.

(7) toLowerCase()– Converts all the characters of the string in lowercase.

(8) toUpperCase()– Converts all the characters of the string in uppercase.

(9) trim()– Remove all the white spaces at the beginning and end of the string.

(10) replace()– Replaces each substring of the string that matches the literal target sequence with the specified literal replacement sequence.

Method | Description |
---|---|
concat() | Appends a string to the end of another string |
toCharArray() | Convert all the characters of a string into a character array. |
compareTo() | Used to compare two strings and the comparison is based on alphabetical order. |
matches() | Tells whether or not this string matches the given regular expression. |
split() | Splits a string into an array of substrings. |
format() | Returns a formatted string using the specified format string and arguments. |
valueOf() | Returns the string representation of the specified value |
copyValueOf() | Returns a String that represents the character sequence in the array specified. |
intern() | Returns a canonical representation for the string object. |
replaceFirst() | Replaces the first substring of the string that matches the given regular expression with the given replacement. |
replaceAll() | Replaces each substring of the string that matches the given regular expression with the given replacement. |
Internet and Its Uses World Wide Web (WWW) Malicious Software (Malware) Database Management System (DBMS) Java (programming language)– Wikipedia |
Comments (No)