class OddException extends Exception
{
OddException(int a)
{
System.out.println("number is odd: " + a);
}
}
class Program10
{
public static void main(String args[])
{
int arr[] = new int[5];
try
{
for(int i=0; i<5; i++)
{
arr[i] = Integer.parseInt(args[i]);
if(arr[i] % 2 != 0)
throw new OddException(arr[i]);
}
}
catch(Exception e)
{
}
}
}
No comments:
Post a Comment