Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
796 B
2
Indexable
Never
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");
                }
            }
        }