创建异常
package P;
public class MyException extends Exception{
MyException(String msg){
super(msg);
}
}
package P;
public class test {
public static void main(String[] args) {
String name="ada";
String age="45";
if(name.equals("ada") && age.equals("45")){
System.out.println("登陆成功");}else{
try {
throw new MyException("用户密码错误");
} catch (MyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
你来是缘分,你走也是