Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java string strip

/**
strip() is an instance method that returns a string whose value is the string with all leading and trailing white spaces removed. This method was introduced in Java 11.

If the string contains only white spaces, then applying this method will result in an empty string.
*/

public class Main {

    public static void main(String[] args) {
        String s = "    ";
        System.out.println(""" + s + "" - "" + s.strip() + """);
        s = "   hello    ";
        System.out.println(""" + s + "" - "" + s.strip() + """);
        s = "h i  ";
        System.out.println(""" + s + "" - "" + s.strip() + """);
    }
}

// OUTPUT

/**

"    " - ""
"   hello    " - "hello"
"h i  " - "h i"

*/
Comment

PREVIOUS NEXT
Code Example
Java :: spring boot example with swagger 
Java :: java check if string appears twice in arraylist 
Java :: finding the ascii value of a character in java 
Java :: java add two arrays together 
Java :: garbage collection in java 
Java :: java indexof nth occurrence 
Java :: Salary example in method in java 
Java :: javax dependency android 
Java :: Java Access superclass attribute 
Java :: remove duplicates from list java 
Java :: what is stringbuilder used for in java 
Java :: arrays vs collections 
Java :: @restcontroller 
Java :: add random numbers to array 
Java :: meaning of instantiated in java 
Java :: implement queue using array in java 
Java :: loops in java 
Java :: is it possible to declare two conditions in for loop in javascrip 
Java :: java check if dates are the same day 
Java :: How to remove an element from a Java List? 
Java :: authentication in spring boot 
Java :: classpath in java 
Java :: run java class file 
Java :: stream reduce stringbuilder 
Java :: Algorithms - sum 
Java :: map indexof java 
Java :: android open app info programmatically 
Java :: Remove ArrayList Elements using remove() function 
Java :: hanoi recursive algorithm 
Java :: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =