Java String Class Methods
The java.lang.String class provides a lot of built-in methods that are used to manipulate string in Java. By the help of these methods, we can perform operations on String objects such as trimming, concatenating, converting, comparing, replacing strings etc.
Java String is a powerful concept because everything is treated as a String if you submit any form in window based, web based or mobile application.
Let's use some important methods of String class.
Java String toUpperCase() and toLowerCase() method
The Java String toUpperCase() method converts this String into uppercase letter and String toLowerCase() method into lowercase letter.
Stringoperation1.javaTest it Now
SACHIN sachin Sachin
Java String trim() method
The String class trim() method eliminates white spaces before and after the String.
Stringoperation2.javaTest it Now
Java String startsWith() and endsWith() method
The method startsWith() checks whether the String starts with the letters passed as arguments and endsWith() method checks whether the String ends with the letters passed as arguments.
Stringoperation3.javaTest it Now
Java String charAt() Method
The String class charAt() method returns a character at specified index.
Stringoperation4.javaTest it Now
Java String length() Method
The String class length() method returns length of the specified String.
Stringoperation5.javaTest it Now
Java String intern() Method
A pool of strings, initially empty, is maintained privately by the class String.
When the intern method is invoked, if the pool already contains a String equal to this String object as determined by the equals(Object) method, then the String from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned.
Stringoperation6.javaTest it Now
Java String valueOf() Method
The String class valueOf() method coverts given type such as int, long, float, double, boolean, char and char array into String.
Java String replace() Method
The String class replace() method replaces all occurrence of first sequence of character with second sequence of character.
Kava is a programming language. Kava is a platform. Kava is an Island.