public class Demo { public static void main(String[] args) { String myStr = " "; if(myStr != null && !myStr.isEmpty() && !myStr.trim().isEmpty()){ System.out.println("String is not null or not empty or not whitespace"); } else { System.out.println("String is null or empty or whitespace"); } } }