1-1-10-6 Java 中如何象在C里面的SCANF那样输入 int 型整数
发信人: bloodflower (雪人), 信区: Java
标题: Re: Java 中如何象在C里面的SCANF那样输入 int 型整数
发信站: BBS 水木清华站 (Thu Oct 26 15:44:41 2000)
【 在 chen28 (水獭) 的大作中提到: 】
: 如题!
//Scanf.java
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));
}
页:
[1]