JAVA Chapter 6.pptVIP

  • 7
  • 0
  • 约1.92万字
  • 约 76页
  • 2016-11-17 发布于天津
  • 举报
JAVA Chapter 6.ppt

5 Exception handling 程序: 从键盘上读取一个数字, 如果读取的不是一个数字, 请提示重新输入,并获取正确的数字. import java.io.*; public class readFile { public static void main(String arg[]) { byte[] b=new byte[34]; double i; while(true) { try{ System.in.read(b); i=Double.parseDouble((new String(b).trim())); System.out.println(the digital is :+i); break; }catch(IOException e) { System.out.println(io error); break; } catch(NumberFormatException e1) { System.out.println(input a right digital......); } } }} 5.1 catch exceptions Th

文档评论(0)

1亿VIP精品文档

相关文档