摘要:
class StackClass{ int[] arr=new int[10]; private int index; public StackClass() { this.index=-1; } public void push(int number) { if(this.index<this.arr.length) this.arr[++index]=number; else System.out.println("Stack is full..."); } public int pop() { if(this.index>=0) return this.a 阅读全文
摘要:
class MyException extends Exception//自定义异常,继承自:Exception{ private int num; public MyException(String msg,int num) { super(msg); this.num=num; } public int getNum() { return this.num; }}class Test { public static void reg(int num) throws MyException//重点是词句。throws MyException 不可缺少。 { if(num<0) { .. 阅读全文