How Java Code 1 Works
- Admin
- Jan 20, 2018
- 1 min read
Updated: Mar 11, 2022
What Is Java Code Sample 1
class MyOwnException extends Exception { public MyOwnException(String msg){ super(msg); } } class EmployeeTest { static void employeeAge(int age) throws MyOwnException{ if(age < 0) throw new MyOwnException("Age can't be less than zero"); else System.out.println("Input is valid!!"); } public static void main(String[] args) { try { employeeAge(-2); } catch (MyOwnException e) { e.printStackTrace(); } } }
More Information:
Rev
Comments