Java String Class strip() method returns a string that provides a string with all leading and trailing white spaces removed. This method is similar to the String.trim() method. There are basically 3 methods by which we can remove white spaces in a different manner.
strip() Method: It returns a string, with all leading and trailing white space removed
String strippedString = string.strip()
stripLeading() Method: It returns a string, with all leading white space removed.
String leadingStripString = string.stripLeading()
stripTrailing() Method: It returns a string, with all trailing white space removed.
String trailedStripString = string.stripTrailing()
Geeks For Geeks Internship ! Geeks For Geeks Internship ! Geeks For Geeks Internship !
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.