
write a program that accepts only 3 integer values as command line arguments.print the values enter by the user. handle ArrayIndexOutofbounds exception and number format exception by providing appropriate message.

import java.io.*;
import java.util.*;
class AcceptNumbers{
public static void main(String[] args){
try{
Scanner input=new Scanner(System.in);
System.out.println("Enter Numbers: ");
int arr[]=new int[3];
for(int i=0;i<arr.length;i++){
arr[i]=input.nextInt();
}
System.out.println("You have entered following numbers: ");
for(int i=0;i<arr.length;i++){
System.out.println(arr[i]);
}
}
catch(ArrayIndexOutOfBoundsException ae){
System.out.println(ae);
}
catch(NumberFormatException ne){
System.out.println(ne);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.