怎么转?在JAVA下没有直接的方法,必须要手工转的吗?
接受用户输入一个整数,这在C++下可是一条语句的事啊!可我从早上开始写这个程序。也问了好几个JAVA高手了,居然现在还没解决!

解决方案 »

  1.   

    这个你也可以试试,看起来应该方便一点!BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    String strValue=input.readLine();
    try{
    int intValue = Integer(a).value();
    }catch(Exception e){//error}
      

  2.   

    再定义一个变量Stirng xx;
    将i = in.readInt();改为
      xx=in.readLine();
      i=Integer.parseInt(xx);
    即可
      

  3.   

    i = in.readInt();
    -->
    i = Integer.parseInt(in.readLine());
      

  4.   

    试一下这个,
    public static void main(String[] args)
    { try
    {
    DataInputStream in = new DataInputStream(new BufferedInputStream(System.in));
    int i;
                            String strToint;
    Point_Demo point1;
    point1 = new Point_Demo();
    System.out.println("input point X:");
                            strToint = in.readLine().trim();
    i = Integer.parseInt(strToint);
    point1.set_X( i );
    System.out.println("input point Y:");
    strToint = in.readLine().trim();
    i = Integer.parseInt(strToint);
    point1.set_Y( i );
    System.out.println("Point set in:(" + point1.get_X() + "," + point1.get_Y() + ")");
    }
    catch(Exception ex)
    {
    System.out.println("Error");
    }
    }