trim() function in String class is used to remove both leading and trailing
(white)spaces of a String.
for example:-
String str = " Hello World ");
System.out.println(str.trim());
will print only "Hello World" in ur console.
note: it will not remove blank spaces in-between the String