import java.io.*;
class test{
public static void main(String args[]) throws IOException {
int c = System.in.read();
int d = 15;
System.out.println(d);
System.out.println(c);
}
}
这段代码运行之后怎么d的打印时正确的,而c的打印的是它的ASCII码?
class test{
public static void main(String args[]) throws IOException {
int c = System.in.read();
int d = 15;
System.out.println(d);
System.out.println(c);
}
}
这段代码运行之后怎么d的打印时正确的,而c的打印的是它的ASCII码?
话说是gbk码吧?我感觉。。貌似应该和系统编码一样吧
改成 char ch= (char)System.in.read();
System.out.println(ch);可以输出字符串
这行代码只是读取你输入的第一个字符的ASCII码。如:你输入的是数字15,读取到的只是1所对应的ASCII码49。
int c=(int)b;
System.out.println(c);