class oddexception extends Exception
{
oddexception(String s)
{
super(s);
}
}
class test2
{
public static void main(String args[])
{
int i,temp=0;
try
{
for(i=0;i<5;i++)
{
int ans=Integer.parseInt(args[i]);
if(ans%2==0)
{
System.out.println(args[i]);
}
else
{
temp++;
throw new oddexception("plz do not enter odd number");
}
}
}
catch(Exception e)
{
System.out.println(e);
}
System.out.println(temp);
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.