Java String trim Example
String class trim method example.
String class trim method example:- This example demonstrates the working of trim method. this method returns same to same data value of a String
Syntax:-trim()
Here is the code:-
/**
* @(#) TrimString.java
* TrimString class demonstrates the working of trim() method of String class of lang package
* @version 16-May-2008
* @author Rose India Team
*/
public class TrimString {
public static void main(String args[]) {
// method 'trim' returns zerox copy of a string
String str = new String("Mangalam bhagwan vishnu");
System.out.println("zerox of String str: " + str.trim());
}
} |
Output of the program:-
| zerox of String str: Mangalam bhagwan vishnu |
|