; Userdef.java
Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out
Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

Userdef.java

VIEWS: 1 PAGES: 1

  • pg 1
									import java.io.*;
class wrongPasswordException extends Exception
{
wrongPasswordException(String a)
{
super(a);     //overriden by toString
}
public String toString()
{
return("WRONG");
}
}

class Userdef
{
public static void main(String ar[])
{
Console c;
c=System.console();
String s="Vesit";
char a[];
try
{
a=c.readPassword();
String p=new String(a);
a=null;
if(p.equals(s))
{System.out.println("Welcome");
p=s=null;}
else
throw new wrongPasswordException("Invalid Password");
}
catch(wrongPasswordException e)
{
System.out.println(e);
System.out.println("Exception caught");
}
}
}

								
To top