| import
java.io.*;
class
myException extends Exception
{
myException()
{ System.out.println("Error:Password too
short");
}
myException(int n)
{ System.out.println("Error:Only adults
can join");
}
}
class
user_exception
{
public static void main(String s[])throws IOException,myException
{ BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
try
{ System.out.print("Enter user name :
");
String n=br.readLine();
System.out.print("Enter your
password : ");
String m=br.readLine();
if(m.length() <6)
throw new myException();
System.out.print("Enter your age :
");
int o=Integer.parseInt(br.readLine());
if(o<18)
throw new myException(o);
}
catch(Exception e)
{
}
}
}
Output
|












