Java - Write code to Determine if the string has at least one letter in upper case

Requirements

Write code to Determine if the string has at least one letter in upper case

Demo

import static org.apache.camel.util.StringQuoteHelper.doubleQuote;

public class Main{
    public static void main(String[] argv){
        String text = "book2s.com";
        System.out.println(hasUpperCase(text));
    }//from www .j  a  v  a  2 s .c o  m
    /**
     * Determines if the string has at least one letter in upper case
     * @param text the text
     * @return <tt>true</tt> if at least one letter is upper case, <tt>false</tt> otherwise
     */
    public static boolean hasUpperCase(String text) {
        if (text == null) {
            return false;
        }

        for (int i = 0; i < text.length(); i++) {
            char ch = text.charAt(i);
            if (Character.isUpperCase(ch)) {
                return true;
            }
        }

        return false;
    }
}

Related Exercise