Program:-
class
InvalidIdException extends Exception
{
InvalidIdException()
{
}
}
class
NumberIsNotValidException extends Exception
{
NumberIsNotValidException()
{
}
}
class
employee
{
public static void main(String
args[])
{
String id = args[0];
String num = args[1];
try
{
if(id.contains("@")
&& id.contains("."))
{
System.out.println("Email
Id is correct: "+args[0]);
}
else
{
throw
new InvalidIdException();
}
if(num.length()==10)
{
System.out.println("Mobile
Number is correct: "+num);
}
else
{
throw
new NumberIsNotValidException();
}
}catch(InvalidIdException
e)
{
System.out.println("Id
has wrong format");
}
catch(NumberIsNotValidException
e)
{
System.out.println("Please
enter correct Number..");
}
}
}
No comments:
Post a Comment