Java String isEmpty
The java string isEmpty() method checks if this string is empty. It returns true, if length of string is 0 otherwise false.
The isEmpty() method of String class is included in java string since JDK 1.6.
Signature
The signature or syntax of string isEmpty() method is given below:
public boolean isEmpty()
Returns
true if length is 0 otherwise false.
Java String isEmpty() method example
public class IsEmptyExample{
public static void main(String args[]){
String s1="";
String s2="javatpoint";
System.out.println(s1.isEmpty());
System.out.println(s2.isEmpty());
}}
Expected Output:
truefalse
No comments:
Post a Comment