Untitled
unknown
plain_text
3 years ago
796 B
8
Indexable
public class TryCatch1 {
public static void main(String[] args) {
try {
int x = 0;
for (String i : args)
{
x += Integer.parseInt(i);
System.out.println("Answer: " + i + x);
}
}catch(ArithmeticException ae){
System.out.println("Arithmatic exception caught\n" + ae);
}catch(NumberFormatException nfe){
System.out.println("Number format exception " + nfe);
}catch(Exception e){
System.out.println("Exception caught: " + e);
}finally{
System.out.println("Finally executed");
}
}
}Editor is loading...