Removes leading and trailing whitespace (Unicode-aware, Java 11+).
Syntax
str.strip()Example
Enter values below to update the example in real time.
String→System→out→println→strip→stripLeading→String s = " Hello Java ";
System.out.println(s.strip()); // "Hello Java"
System.out.println(s.stripLeading()); // "Hello Java "