2:21 am - Wednesday April 26, 2017

Check whether a given string is empty boolean isEmpty()

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

                                This method return true or false value. If the string variable contains any string value it return false,Otherwise it return true(If the input is empty). To return true or false value mention the method modifier as boolean.

Example Program

    public class Empty {

    public static void main(String args[])


          String s1="Java String Handling Functions";

          System.out.println("String is:"+s1+"\n");

          System.out.println("Length of the string:"+s1.length()+"\n");

          System.out.println("Is the string Empty:"+s1.isEmpty());




       String is:Java String Handling Functions

       Length of the string:30

       Is the string Empty:false


                          Here the given string is “Java String Handling Functions”. If the length of the given string is 0 means it returns true,otherwise it return false. In the above program, length of the given string is 30 so it return false.

Filed in: Java Examples

Comments are closed.