13
Dec
Method to remove extra white space:
String.trim();
A simple Java program:
public class Main {
public static void main(String[] args) {
String s = " Hello Java "; //adding white space before and after string
System.out.println(s.trim());
}
}
Output:
Hello java //after removing white space
Leave a Reply