stripTrailing() method of String class

stripTrailing() method has been introduced in String class of Java 11. It is used to remove all the trailing white space characters from the string and return the remaining string. It means it removes white spaces that come at the end of string. If the string only contains the white spaces then an empty string is returned. Let us … Read more

stripLeading() method in String class

stripLeading() method has been introduced in String class of Java 11. It is used to remove all the leading white space characters from the string and return the remaining string. It means it removes white spaces that comes at beginning of the string. If the string only contains the white spaces then an empty string … Read more

strip() method in String class

In Java 11 a new method strip() has been introduced in String class. It is used to remove all the trailing and leading white space characters from the string. strip() method returns the string after removing these white spaces. If the string only consists of white spaces then an empty string is returned. Let us … Read more

isBlank() vs isEmpty() in String class Java

isBlank() is a new method introduced in String class in Java. By naming isBlank() and isEmpty() methods look similar to each other, but there is a slight difference between them – isBlank() returns true for the string having only white space characters whereas isEmpty() will return false for such strings. Let us understand the difference … Read more