string.isEmpty()
String.isEmpty() Checks if the string is empty or not.
Syntax
String1.isEmpty(String2)
Return value is boolean ( true or false )
Here are some examples with output.
String str1 = "";
String str2 = "plus2net";
System.out.println(str1.isEmpty()); // true
System.out.println(str2.isEmpty()); // false
Checking a null string
It returns exception.
String str3=null;
System.out.println(str3.isEmpty());
Exception in thread "main" java.lang.NullPointerException
« All String functions
« Java
This article is written by plus2net.com team.
plus2net.com