String str = new String(" apples ");
str.trim(); // result is a nes string "apple"
public class StringSpaces {
public static void main(String[] args) {
String str = " Hello World ";
str = str.trim();
System.out.println("String- " + str);
}
}