is All Upper Case Where Possible - Java java.lang

Java examples for java.lang:String Case

Description

is All Upper Case Where Possible

Demo Code


public class Main{

    public static void main(String[] argv){
        String s = "java2s.com";
        System.out.println(isAllUpperCaseWherePossible(s));
    }/* w w  w  . j  av  a2  s  . co  m*/
    public static boolean isAllUpperCaseWherePossible(CharSequence cs) {
        if (cs == null || isEmpty(cs)) {
            return false;
        }
        int sz = cs.length();
        for (int i = 0; i < sz; i++) {
            char ch = cs.charAt(i);
            if (Character.isLowerCase(ch)) {
                return false;
            }
        }
        return true;
    }

}

Related Tutorials