why i am getting arrayindexoutofboundexception
import java.util.Scanner; class Main { public static void main(String args[]) { System.out.println("Program to check if a number is already available in array or not."); Scanner sc=new Scanner(System.in); int i,n; System.out.println("Enter the size of array please:"); n=sc.nextInt(); int arr[]=new int[n]; System.out.println("*************Enter elements in array:****************"); for(i=0;i<n;i++) { System.out.println("Element at index:"+i); arr[i]=sc.nextInt(); } System.out.println("**************You Entered:**************"); { for(i=0;i<n;i++) System.out.println("Entered lement at index:"); System.out.println(arr[i]); } } }