问个java 异常类的问题 ,高手进

来源:百度知道 编辑:UC知道 时间:2024/05/05 03:04:17
以下代码 如果能通过编译,会出现什么的打印结果?
import java.io.DataInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

class Base{
public static void amethod()throws FileNotFoundException{}
}

public class ExceptDemo extends Base {
public static void main(String[] args) {
ExceptDemo e = new ExceptDemo();

}
public static void amethod(){}

protected ExcepDemo() throws IOException{
DataInputStream din = new DataInputStream(System.in);
System.out.println("pausing");
din.readChar();
System.out.println("Continuing");
this.amethod();
}
}

高手解释一下,运行 流程。。。谢谢,初学 的我

这个类写错了,protected ExcepDemo() throws IOException这句Demo()后面要加void
这是一个IO流的类system.in就是你在cmd面板输入的内容,你运行它的时候你在面板输入值他打印出pausing
din.readChar();就是读入输入的这个16位字符readChar();是IO里面的一个方法,读完字符之后在打印continuing,然后返回amethod()这个方法

自己测试下就知道啦。。。

你这是什么东西? 神也看不懂 谁这么写异常类啊 牛X

异常类要扩展自Exception类.