Java - Write code to create a method check if a string is Not Blank

Requirements

Write code to create a method check if a string is Not Blank

Demo

//package com.book2s;

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

    public static boolean isNotBlank(String str) {
        int length;

        if ((str == null) || ((length = str.length()) == 0)) {
            return false;
        }

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

        return false;
    }

}

Related Exercise