Userdef.java

					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");
}
}
}

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:1
posted:6/26/2012
language:
pages:1