Java String Methods

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.

equals() java string method

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

equalsIgnoreCase() Java string method

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

charAt() java string method

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

java string method length()

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

indexOf() java string method

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

isEmpty() java string method

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

toLowerCase() java string method

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

toUpperCase() java string method

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

trim() java string method

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

replace() java string method
MethodDescription
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)

Leave a Reply