?? nullexceptiondemo.java
字號:
class Car
{
void startengine(){};
}
public class NullExceptionDemo{
Car mycar;
void start() throws InstantNotInitException{
if (mycar==null) throw new InstantNotInitException("mycar is null");
mycar.startengine();}
public static void main(String args[]){
NullExceptionDemo demo=new NullExceptionDemo();
try{
demo.start();
System.out.println("start car");
return;
}catch(InstantNotInitException e){
System.out.println("Got exception:"+e.getMessage()); }}
}
class InstantNotInitException extends Exception{
public InstantNotInitException(){}
public InstantNotInitException(String message) {super(message);}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -