String text = "Hello, world!"; if (StringUtil.isNotEmpty(text)) { System.out.println("The text is not empty!"); } else { System.out.println("The text is empty!"); }
String text = ""; if (StringUtil.isNotEmpty(text)) { System.out.println("The text is not empty!"); } else { System.out.println("The text is empty!"); }Output: The text is empty! In this example, we initialize the string variable called text with an empty string. When we pass this string to the isNotEmpty() method, it will return false since the string is empty. As a result, the output will be "The text is empty!". Package library: com.intellij.openapi.util.text StringUtil belongs to the IntelliJ IDEA Java Development Environment (JDE) library.