Java String Trim Method
Chapter:
String Handling
Last Updated:
15-05-2017 15:21:50 UTC
Program:
/* ............... START ............... */
public class JavaStringTrimMethod {
public static void main(String args[]) {
String str = " She sells sea shells on the sea shore ";
System.out.println("Input string is: ");
System.out.println(str);
System.out.println("After trimming, the result is:");
System.out.println(str.trim());
}
}
/* ............... END ............... */
Output
Input string is:
She sells sea shells on the sea shore
After trimming, the result is:
She sells sea shells on the sea shore
Tags
String Trim Method, String, Java