Java - Write code to check if a string is Null Or Empty by comparing with empty space

Requirements

Write code to check if a string is Null Or Empty by comparing with empty space

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(isNullOrEmpty(str));
    }/* ww w  .ja  va2s  . c  o m*/

    public static boolean isNullOrEmpty(String str) {
        if (str == null || str.equals(" ")) {
            return true;
        }

        for (char c : str.toCharArray()) {
            if (c != ' ') {
                break;
            }
        }

        return false;
    }
}