str="Test";
str2=str.toUpperCase();
if (str==str2)
{
//说明str里没有小写字母。
}/*
用toUpperCase(),
方法是,如果str中本身全是大写字母,则str2=str.toUpperCase()和str指向同一个对象。
*/
str2=str.toUpperCase();
if (str==str2)
{
//说明str里没有小写字母。
}/*
用toUpperCase(),
方法是,如果str中本身全是大写字母,则str2=str.toUpperCase()和str指向同一个对象。
*/
应该是strcmp(str,str2)==0吧??
str2=str.toUpperCase();
if (str.equals(str2))
{
//说明str里没有小写字母。
}
同理
str="Test";
str2=str.toLowerCase();
if (str.equals(str2))
{
//说明str里没有大写字母。
}
str2=str.toUpperCase();
if (str.equals(str2)) {
return false;//没有小写字母
}
return true;//有小写字母
}
import java.util.regex.*;
....
String str="Test";
System.out.println(Pattern.matches("[^a-z]*",str));
...
if (str.equals(str2))