Java String isEmpty Example
String class isEmpty method example
String class isEmpty method example:- This method returns boolean value true if and only if .length methodreturns for the object taken under process and returns false if object chosen is not empty that means it has .length() method value greater than zero.
Syntax:- isEmpty()
Here is the code:-
/**
* @(#) IsEmptyString.java
* IsEmptyString class demonstrates the working of isEmpty() method of String class of lang package
* @version 16-May-2008
* @author Rose India Team
*/
public class IsEmptyString {
public static void main(String args[]) {
String heram = new String("heram");
// Method isEmpty() returns boolean value false if and only if length of
// the value is zero
// .length() method returns the lenght of
System.out.println("length of the method is returned: "
+ heram.length() + "\n" + "Method returns false here: "
+ heram.isEmpty());
}
} |
| Java2html |
Output of the program:-
length of the method is returned: 5
Method returns false here: false |
|