public class chinese
{
public static void main (String [] args)
{
chinese ch=new chinese();
boolean st=ch.hasChinese("谢谢");
System.out.println(st);
}
public static boolean hasChinese(String value) {
boolean blFind; blFind = false;
byte[] valueBytes = value.getBytes();
for (int j = 0; j < value.length(); j++) {
if (valueBytes[j] < 0)
{
blFind = true;
break;
}
}
return blFind;
}
}
{
public static void main (String [] args)
{
chinese ch=new chinese();
boolean st=ch.hasChinese("谢谢");
System.out.println(st);
}
public static boolean hasChinese(String value) {
boolean blFind; blFind = false;
byte[] valueBytes = value.getBytes();
for (int j = 0; j < value.length(); j++) {
if (valueBytes[j] < 0)
{
blFind = true;
break;
}
}
return blFind;
}
}
{
public static void main (String [] args)
{
chinese1 ch=new chinese1();
boolean st=ch.hasChinese("谢谢");
System.out.println(st);
}
public static boolean hasChinese(String value1)
{
byte[] valueBytes = value1.getBytes();
System.out.println(value1.length());
System.out.println(valueBytes.length);
return value1.length() != valueBytes.length;
}
}
输出结果为:2,4,true!