《java语言基础教程》p296
Console 是 final 类呀 怎么可以坐父类呢?
public class ShortStringReader extends Console { private final static int MAX = 10; public ShortStringReader() throws LongStringException{ // TODO Auto-generated constructor stub if(super.readString().length() <= MAX) return super.readString(); else throw new LongStringException("String to long. MAX:" + MAX); } }
p300
在Quotient()中已经catch到了ArithmeticException 干吗还throws 呢
public class Main { static void Quotient(int n, int d){// throws ArithmeticException { try { System.out.println(n/d); } catch (ArithmeticException e) { System.out.println(e); } } public static void main(String[] args) { int numer = 10; int denom = 0; Quotient(numer, denom); } }