String objects and string characters can be checked for empty or not empty with the help of isEmpty() method in java. isEmpty() method returns value in boolean. If string length is 0, it will return true, otherwise false. Use of String isEmpty() in java is shown below.
Example of String isEmpty() in java, JSP
public class StringIsEmptyExample { public static void main(String[] args) { String string1 = "isEmpty java strings"; boolean checkString1 = string1.isEmpty(); String string2 = ""; boolean checkString2 = string2.isEmpty(); System.out.println("checkString1 isEmpty String method :"+checkString1); System.out.println("checkString2 isEmpty String method :"+checkString2); } }
Output
checkString1 isEmpty String method :false
checkString2 isEmpty String method :true
Tags: String



Link to Us