Hi there,
Figured out the other part...
Now this part..
I have to convert MM/DD to word format, eg:
1/17 to 17 January
Is there an easier way to do this than if/switch/etc?
Printable View
Hi there,
Figured out the other part...
Now this part..
I have to convert MM/DD to word format, eg:
1/17 to 17 January
Is there an easier way to do this than if/switch/etc?
To create your own exception, extend Exception or RuntimeException (depending on whether you want a check or an uncheck exception)
Code :public class MyException extends Exception {}// really no code needed, it's all in the Exception class
here simple program.
1. public class Excep16 {
public static void main(String[] args) {
try{
for(int cnt = 0; cnt < 5; cnt++){
if(cnt == 5) throw new MyException("number is 3");
}
}
catch(MyException e){
System.out.println("In exception handler, "+ "get the message\n" + e.getMessage());
}
System.out.println("Out of catch block");
}
}
2.
public class MyException extends Exception{
MyException(String message){
super(message);
}
}