Wednesday 18 June 2014

isEmpty()

public boolean isEmpty()
Returns true if, and only if, length() is 0.

class StringIsEmpty{
 public static void main(String args[]){
  String s1 = "";
  String s2 = " ";
  
  System.out.println("Is s1 empty " + s1.isEmpty());
  System.out.println("Is s2 empty " + s2.isEmpty());
 }
}

Output
Is s1 empty true
Is s2 empty false

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment