I was finding out highest prime factor which divides num, as shown in program, there\'s a issue with array and
arr[j] = i; j++;
Excepti
Arrays in java are not lists: once allocated, your array won't grow magically.
You created the array with: int arr[] = {j}; thus the array has one cell only.
int arr[] = {j};
You should initialise your array with at least num/2 cells, with something like int arr[] = new int[num/2]; arr[0] = j;
num/2
int arr[] = new int[num/2]; arr[0] = j;