Java 中如何象在C里面的SCANF那样输入 int 型整数

发表于:2007-06-22来源:作者:点击数: 标签:

   
  import java.io.*;
public class Scanf{
public static void main(String[] args)
{
DataInputStream din=new DataInputStream(System.in);
String str;
int a=0;

System.out.print("Input the integer number:");
System.out.flush();

try{
str=din.readLine();
a=Integer.parseInt(str);
}
catch (NumberFormatException e)
{}
catch (IOException e )
{}
System.out.println("The number you input is:"+Integer.toString(a));

}

}

原文转自:http://www.ltesting.net