public static void main(String...args){
String str = "A1B2";
char ch = str.charAt(1);
System.out.println(ch);//1
System.out.println(ch==1);//false
System.out.println((int)ch == 1);//false
System.out.println(String.valueOf(ch).equals("1"));//true
}为什么前两个都是false?
String str = "A1B2";
char ch = str.charAt(1);
System.out.println(ch);//1
System.out.println(ch==1);//false
System.out.println((int)ch == 1);//false
System.out.println(String.valueOf(ch).equals("1"));//true
}为什么前两个都是false?
System.out.println(ch==1)里的ch是unicode编码对应的数字,不是1,具体是什么数需要查查。。
如果是ASCII,char占两个字节要怎么编码?