Write a program to accept a password from the user and throw 'AuthenticationFailure' execption if the password is incorrect

import java.io.*;
class AuthenticationFailureException extends Exception
{
 AuthenticationFailureException(String msg)
 {
  super(msg);
 }
}
class Exp8_1
{
 public static void main(String[] args) 
 {
  String pass, conf_pass;
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  try
  {
   System.out.println("Enter Password: ");
   pass = br.readLine();
   System.out.println("Re-Enter Password: ");
   conf_pass = br.readLine();
   if(!pass.equals(conf_pass))
    throw new AuthenticationFailureException("Incorrect Password");
   else
    System.out.println("Password Accepted");
  }
  catch (AuthenticationFailureException ob)
  {
   System.out.println(ob);
  }
  catch(IOException ioe)
  {}
 }
}
/*  OUTPUT!!!
Enter Password:
abc123
Re-Enter Password:
ABC123
AuthenticationFailureException: Incorrect Password
*/
Copyright © LetML. Blogger Templates Designed by OddThemes