I am beginner in Java. I wrote a few lines of code, and it is showing error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
import java.util.Scanner;
public class Issue {
public static Scanner scan = new Scanner(System.in);
int n;
int ID[]=new int[n];
String [] Name=new String[n];
public void get()
{
int ID[] = new int[n];
for (int i = 0; i < n; i++) {
System.out.println("Enter " + (i+1) + "st Employe ID :");
ID[i] = scan.nextInt();
System.out.println("Enter Employe Name:");
Name[i]=scan.nextLine();
}
}
public static void main(String[] args) {
Issue obj=new Issue();
System.out.println("Enter no.of Employes:");
obj.n=scan.nextInt();
obj.get();
}
}