Commit d44c06f8 authored by Suresh Kumar's avatar Suresh Kumar

Exception-Handling

parent 6c965654
package customclass.com;
class CustomException extends Exception {
String str;
CustomException(String str){
this.str=str;
}
public String toString(){
return ("Message " + str );
}
}
\ No newline at end of file
package customclass.com;
public class UserDefined {
static void validation(String name) throws CustomException{
if (name == null){
throw new CustomException(": Access Denied Due To Username or Password-----> Check Username & Password");
} else {
System.out.println("-------- You Have Successfully Logined-----------");
}
}
public static void main(String [] args){
try {
validation(null);
}
catch (CustomException e){
System.out.println( e);
}
System.out.println("\n------------Custom-Exception---------------");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment