ch06 异常操作.docVIP

  • 5
  • 0
  • 约1.34万字
  • 约 17页
  • 2016-12-03 发布于河南
  • 举报
ch06 异常操作

第六章 异常 “异常”指的是程序运行时出现的非正常情况。Java对“异常”的处理是面向对象的。在Java中用类Exception及其子类来处理异常。当出现“异常”情况时,一个Exception对象就产生了。 第一节 常见异常及其处理 一、被0除异常 import java.util.Scanner; public class ArithmeticExceptionDemo { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println(输入被除数); int a = sc.nextInt(); System.out.println(输入除数); int b = sc.nextInt(); System.out.println(a + 除以 + b + = + a / b); } } 执行结果: Exception in thread main java.lang.ArithmeticException: / by zero at ArithmeticExceptionDemo.main(Arithmeti

文档评论(0)

1亿VIP精品文档

相关文档