| 
 | 
 
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册 
 
 
 
×
 
 
- 发信人: 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));
 
  
-     }
 
  
  复制代码 |   
 
 
 
 |