check if blank string java code example
Example 1: check if a string is empty java
if (myString == null || myString.equals(""))
throw new IllegalArgumentException("empty string");
Example 2: java string util if empty default
String emptyString = new String();
result = StringUtils.defaultIfEmpty(emptyString, "default");
System.out.println(result);
String nullString = null;
result = StringUtils.defaultIfEmpty(nullString, "default");
System.out.println(result);