你忘了捕获异常了.
public class Readhello {
public static void main(String args[]) {
try {
int inChar;
inChar=System.in.read();
System.out.println("you entered"+inChar);
}catch(Exception e){}
}
}
public class Readhello {
public static void main(String args[]) {
try {
int inChar;
inChar=System.in.read();
System.out.println("you entered"+inChar);
}catch(Exception e){}
}
}
public static void main(String args[]) {
try {
test();
}catch(Exception e){}
}
public static test() throws Exception {
int inChar;
inChar=System.in.read();
System.out.println("you entered"+inChar);
}
try { do something ;
}catch(Exception e){ something
}
{
public static void main(String args[])
{
try
{
int inChar;
inChar=System.in.read();
System.out.println("you entered"+inChar);
}
catch(IOException e)
{
System.out.println(e);
}
}
}
//这样就可以了