62,614
社区成员
发帖
与我相关
我的任务
分享
import java.io.*;
class MyException extends Exception {
private String reason;
public MyException(String r) {
reason = r;
}
public String getReason() {
return (reason);
}
}
class Excp {
private String s;
public Excp(String ss) throws MyException {
s = ss;
if (s.equals("XYZ")) {
throw new MyException("This is a XYZ");
}
}
}
public class Test_Excp {
public static void main(String args[]) throws Exception {
System.out.println("Plz input s1:");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String s1 = in.readLine();
try {
Excp e1 = new Excp(s1);
} catch (MyException e) {
System.out.println("ddfd");
}
}
}