package MyException;
public class MyException extends Exception {
public MyException(String str)
{
super(str);
}
}
package MyException;
public class mainClass
{
public static void main(String args[])
{
try
{
int n = 105;
if(n<199)
throw new MyException(n+" is less than 199");
}catch (MyException e)
{
System.out.println(e.getMessage());
}
}
}
Output =>
105 is less than 199
public class MyException extends Exception {
public MyException(String str)
{
super(str);
}
}
package MyException;
public class mainClass
{
public static void main(String args[])
{
try
{
int n = 105;
if(n<199)
throw new MyException(n+" is less than 199");
}catch (MyException e)
{
System.out.println(e.getMessage());
}
}
}
Output =>
105 is less than 199
No comments:
Post a Comment