package com.demo.ExceptionDemo;
public class ExceptionDemo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// try{
new Excep().add();
//}catch(ArithmeticException e){
// e.printStackTrace();
// }
try{
test();
}catch(myException e){
System.out.println(e);
}
}
public static void test()throws myException{
int age=-10;
if(age<0){
throw new myException("hello exception");
}
}
}
class Excep{
int i=5,j=0;
public void add()throws ArithmeticException{
try{
int k=i/j;
System.out.println(k);
}catch(ArithmeticException e){
System.out.println(e);
}
}
}
class myException extends Exception{
/**
*
*/
private static final long serialVersionUID = 1L;
String message;
public myException(String message){
this.message = message;
}
public String getMessage(){
return message;
}
}
public class ExceptionDemo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// try{
new Excep().add();
//}catch(ArithmeticException e){
// e.printStackTrace();
// }
try{
test();
}catch(myException e){
System.out.println(e);
}
}
public static void test()throws myException{
int age=-10;
if(age<0){
throw new myException("hello exception");
}
}
}
class Excep{
int i=5,j=0;
public void add()throws ArithmeticException{
try{
int k=i/j;
System.out.println(k);
}catch(ArithmeticException e){
System.out.println(e);
}
}
}
class myException extends Exception{
/**
*
*/
private static final long serialVersionUID = 1L;
String message;
public myException(String message){
this.message = message;
}
public String getMessage(){
return message;
}
}