0
Meaning of trim() function in java ?
string
2 Respuestas
+ 1
When applied to a string of characters, it removes the leading and trailing spaces, that is, it deletes the whitespaces at the beginning and at the end.
+ 1
Basically , trim() is an inbuilt method present in java.lang of String class.Basically importing java.lang package is completely optional because it is imported by default by the compiler when ever we open a new .java file.
When applied on a string , it removes starting and leading spaces of the string.
For example:-
String s1=" Hello Sololearn ";
String s2=s1.trim();
System.out.println(s2);
//s2 becomes "Hello Sololearn"