Hope this is better. I am writing a java assignment to implement a sorting technique. I used a scanner
object within a loop to input user data to be sorted. However the scanner
object continues to read data after array is filled and an index out of bounds error is shown. How do I deal with this.
public static void set1(int N)
{
int i,c,e,f;
double a,b;
int[] arr1 = new int[N];
int[] arr2 = new int[N];
System.out.println("Please enter numbers to be sorted");
for(i=0;i<=N;i++)
{
Scanner Secondin = new Scanner(System.in);
arr1[i] = Secondin.nextInt();
}
}