public class Try
{public static void main(String args[])
 throws java.io.IOException
  {int x;
   x=System.in.read();
   System.out.println(+x);
  }
}
我要使输入一个整数,再输出它,怎么写???,上面的个程序为什么总是输出它的ASCII值呢???多谢各位了

解决方案 »

  1.   

    版主能不能帮我强行结贴呀,谢谢了
    自己答了算了 
    //显示输入面板的例子
    import javax.swing.JDialog;
    import javax.swing.JOptionPane;
    public class JOptionPane
    {
      public static void main(String[] args)
            {String A=JOptionPane.showInputDialog("please inprint number!");
             int B=Integer.parseInt(A);
             int C=B;
             JOptionPane.showMessageDialog(null, C, "B", JOptionPane.ERROR_MESSAGE); 
             System.exit(0);
    }
    }
      

  2.   

    int x;
       x=System.in.read();
       System.out.println(+x);
    换成
    String x;
       x=System.in.readline();
       System.out.println(x);
      

  3.   

    import java.io.*;
    class AAA 
    {
    public static void main(String[] args) 
    {
    try{
    int x;
    x=System.in.read();
    System.out.println((char)x);
    } catch(Exception e) {
    e.printStackTrace();
    }
    }
    }
    100%好使,多谢,尽快散分!:)
      

  4.   

    import javax.swing.JDialog;
    import javax.swing.JOptionPane;
    public class JOptionPane {
    public static void main(String[] args) {
    String A=JOptionPane.showInputDialog("please inprint number!");
    int B=Integer.parseInt(A);
    int C=B;
    JOptionPane.showMessageDialog(null, C, "B", JOptionPane.ERROR_MESSAGE); 
    System.exit(0);
    }
    }
    都不能用,我以为是什么好东西
      

  5.   

    楼上的,版主的程序有点问题,修改一下就可以了
    int C=B;修改为Integer C = new Integer(B);
    程序如下:
    import javax.swing.JDialog;
    import javax.swing.JOptionPane;
    public class tttt {
    public static void main(String[] args) {
    String A=JOptionPane.showInputDialog("please inprint number!");
    int B=Integer.parseInt(A);
    Integer C=new Integer (B);
    JOptionPane.showMessageDialog(null, C, "B", JOptionPane.ERROR_MESSAGE); 
    System.exit(0);
    }
    }
      

  6.   

    数据类型不匹配,System.in.read();返回的是String型的.int x为int 型肯定不行了.
      

  7.   

    import java.io.*;
    public class T   {        public static void main(String[]   args)
    {
                    try{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    while(true)
    {
    String x = br.readLine();
    if(x.equals("exit"))
    break;
    System.out.println(x);
    }
    } catch(Exception e) {
    e.printStackTrace();
    }        }
    }