How to check if a String has no characters, is empty using isEmpty() in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        try {

            String s = "";
            if (s.isEmpty()) {
                System.out.println("String is empty");
            }

        } catch (Exception e) {
            System.out.print(e.toString());
        }
    }
}

/*
            
run:
      
String is empty
   
 */

 



answered Nov 22, 2016 by avibootz

Related questions

1 answer 166 views
1 answer 143 views
1 answer 165 views
1 answer 171 views
2 answers 269 views
1 answer 136 views
1 answer 147 views
...