Java - Write code to check if a string is Blank value using if statement

Requirements

Write code to check if a string is Blank value using if statement

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(isBlank(str));
    }//w w w .  ja v a 2s  .  co  m

    public static boolean isBlank(String str) {
        if (str == null) {
            return true;
        }
        if (str.trim().length() == 0) {
            return true;
        }
        if (str.equals("")) {
            return true;
        }
        if (str.equals("null") || str.equals("NULL")) {
            return true;
        }
        return false;
    }
}

Related Exercise