class Lesson22
{
public static void main(String args[])
{
char a='1';
try {
a = System.in.read();
}
catch (Exception e){}
while(a!='q')
{
System.out.println((char)a);
try {
a = System.in.read();
}
catch (Exception e){}
}
}
}
}
提示:possible loss of precisionclass Lesson22
{
public static void main(String args[])
{
int a=1;
try {
a = System.in.read();
}
catch (Exception e){}
while(a!='q')
{
System.out.println((char)a);
try {
a = System.in.read();
}
catch (Exception e){}
}
}
}
}
就是正确的,我错在那里啊
{
public static void main(String args[])
{
char a='1';
try {
a = System.in.read();
}
catch (Exception e){}
while(a!='q')
{
System.out.println((char)a);
try {
a = System.in.read();
}
catch (Exception e){}
}
}
}
}
提示:possible loss of precisionclass Lesson22
{
public static void main(String args[])
{
int a=1;
try {
a = System.in.read();
}
catch (Exception e){}
while(a!='q')
{
System.out.println((char)a);
try {
a = System.in.read();
}
catch (Exception e){}
}
}
}
}
就是正确的,我错在那里啊
在第一个程序你直接用char 型的a来接受System.in.read()当然会出现缺失精度的问题了
第一个程序中改成 a=(char)System.in.read()
the next byte of data, or -1 if the end of the stream is reached. ^_^,去看一下jdk文档吧 !