str="Test";
str2=str.toUpperCase();
if (str==str2)
{
   //说明str里没有小写字母。
}/*
用toUpperCase(),
方法是,如果str中本身全是大写字母,则str2=str.toUpperCase()和str指向同一个对象。
*/

解决方案 »

  1.   

    str==str2????
    应该是strcmp(str,str2)==0吧??
      

  2.   

    str="Test";
    str2=str.toUpperCase();
    if (str.equals(str2))
    {
       //说明str里没有小写字母。
    }
    同理
    str="Test";
    str2=str.toLowerCase();
    if (str.equals(str2))
    {
       //说明str里没有大写字母。
    }
      

  3.   

    public boolean checkLower(String str) {
    str2=str.toUpperCase();
    if (str.equals(str2)) {
      return false;//没有小写字母
    }
    return true;//有小写字母
    }
      

  4.   

    正则表达式方法:
    import java.util.regex.*;
    ....
    String str="Test";
    System.out.println(Pattern.matches("[^a-z]*",str));
    ...
      

  5.   

    str2=str.toUpperCase();
    if (str.equals(str2))