/* Program that throws a 'NoMatchException' when a string is not equal to “India” */
class NoMatchException extends Exception
{
private String str;
NoMatchException(String str1)
{
str=str1;
}
public String toString()
{
return "NoMatchException --> String is not India and string is "+str;
}
}
class P31
{
public static void main(String args[ ])
{
String str1= new String("India");
String str2= new String("Pakistan");
try
{
if(str1.equals("India"))
System.out.println(" String is : "+str1);
else
throw new NoMatchException(str1);
if(str2.equals("India"))
System.out.println("\n String is : "+str2);
else
throw new NoMatchException(str2);
}
catch(NoMatchException e)
{
System.out.println("\nCaught ...."+e);
}
}
}
class NoMatchException extends Exception
{
private String str;
NoMatchException(String str1)
{
str=str1;
}
public String toString()
{
return "NoMatchException --> String is not India and string is "+str;
}
}
class P31
{
public static void main(String args[ ])
{
String str1= new String("India");
String str2= new String("Pakistan");
try
{
if(str1.equals("India"))
System.out.println(" String is : "+str1);
else
throw new NoMatchException(str1);
if(str2.equals("India"))
System.out.println("\n String is : "+str2);
else
throw new NoMatchException(str2);
}
catch(NoMatchException e)
{
System.out.println("\nCaught ...."+e);
}
}
}
5 comments:
Output?
i loved this high quality replica bags look what i found louis vuitton replica his explanation best replica designer bags
j7h70j0p71 f6e29m1u42 k3g76k2j72 h3q35l3p24 y8n30q0j67 h7t08l8x50
cheap jordans
off white hoodie
air jordan
bape
jordan shoes
kobe byrant shoes
off white
supreme
off white jordan 1
palm angels
kevin durant shoes
off white jordan
yeezy
supreme
bape
nike off white
nike dunks
russell westbrook shoes
yeezy
golden goose
Post a Comment