import java.io.*;public class LittleTest{
   public static void main (String[] args) throws IOException
{
System.out.println ("请输入一个整数数值:");
int a=System.in.read();
System.out.println ("打印出输入的值a="+a);
}
}
//输出结果如下:
请输入一个整数值:
25
50Process completed.//疑问
不应该就是25嘛?怎么的输出就变成50了!
感激涕零o(∩_∩)o...

解决方案 »

  1.   

    readpublic abstract int read()
                      throws IOException    Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.    A subclass must provide an implementation of this method.    Returns:
            the next byte of data, or -1 if the end of the stream is reached. 
        Throws:
            IOException - if an I/O error occurs.
      

  2.   

    System.in.Read()只接叫一个字符,所以无论是"2"或者"250"还是"2sfsd"输出的结果都是"50"这里给你写一个可以用的例子import java.util.Scanner;public class Demo { public static void main(String[] args){
    Scanner s=new Scanner(System.in);
    System.out.print ("请输入一个整数数值:"); 
    String a=s.nextLine(); System.out.println ("打印出输入的值a="+a);  }

    }
      

  3.   

    的确是这样,system.in.read()获取的是一个字节。
    25 的话 获取 2,并返回2的ascii码50
    system.out.print直接输出50
      

  4.   

    楼上正解。读取命令行不要用read.
      

  5.   

    system.in.read()获取的是一个字节。 
    25 的话 获取 2,并返回2的ascii码50 得字符串我用
    String info = new javax.swing.JOptionPane().showInputDialog("Input:");还可以用fileReader吧?忘了。