I take the size of the array in a variable in a loop. Every time I have to assign an array size equal to this variable, and then take integers equal to this size. For instance:
for(i = 0; i < N; i++)
{
variable = sc.nextInt();
int []array = new int[variable];
for(j = 0; j < variable; j++)
{
array[j] = sc.nextInt();
}
}
Please provide me with the most efficient method since I am new to java :)
source
share