import java.i0.*;
String tempStr=null;
int temInt ;
try{
    BufferedReader in=new BufferedReader(
                         new InputStreamReader(System.in));
    tempStr=(String)in.readLine();
}catch(IOException e){
     //do noting
}
temInt = Integer.parseInt(temStr);

解决方案 »

  1.   

    ...
    int i = System.in.readInt();
    ...
      

  2.   

    String s;
    Integer.parseInt(s);如果抛出NumberFormatException则说明s不是一个合法的数字
      

  3.   

    int i = System.in.read();//好象没有System.in.readInt()方法
      

  4.   

    import   java.lang.*;
    import   java.io.*;
    public class  trangle{
      
      public  static void main(String args[]){
             int  edge1;
             int  edge2;
             int  edge3;
             Integer  num=new Integer();
             System.out.println("please input the first edge:");
             edge1=num.intValue();
             System.out.println("please input the second edge:");
             edge2=num.intValue();            
             edge3=(edge1*edge1+edge2*edge2);
             System.out.print("the thrid edge is that:");
             System.out.println(edge3);         
            }
    }
    我的错在哪
      

  5.   

    import java.io.*;
    import java.util.*;class test
    {
    public static void main(String args[])
    {
    int a ;
    System.out.println("请输入一个整数:");
    try 
    {
    BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
                String strIn = is.readLine();   
    try{
      a = Integer.parseInt(strIn);
    }
    catch(java.lang.NumberFormatException nex){
    System.out.println("The input number is invalid,a = 10");
    a = 10;
    }
    System.out.println("a = "+a);
                    }
           }
    }
      

  6.   

    SORRY,第一个try对应的catch写掉了!!!1