Java - Write code to check if a string contains Non Whitespace Characters

Requirements

Write code to check if a string contains Non Whitespace Characters

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "book2s.com";
        System.out.println(containsNonWhitespaceCharacters(str));
    }//from w  ww .  ja va 2  s .  c  om

    public static boolean containsNonWhitespaceCharacters(String str) {
        if (str == null) {
            return false;
        }

        for (int i = 0; i < str.length(); i++) {
            if (!Character.isWhitespace(str.charAt(i))) {
                return true;
            }
        }

        return false;
    }
}