0
Array input
for(int i=0;I<at.length;i++) { ar[i]=new int[sc.nextInt()]; } Generates an error saying incompatible types: int[] cannot be converted to int In the body of the loop.
3 Answers
0
if you want input int and store it to int[] array:
import ...Scanner..
...
int[] at = new int[5];
int[] r = new int[5];
// init sc ...
for(int i=0; i<at.length; i++) //lowercase i<
{
r[i] = sc.nextInt();
}
+ 5
ar[i] denotes some value in array ar at index i, while new int [sc.nextInt()] denote some array of size sc.nextInt() so you can't store int array in int type variable
Utkarsh
can you provide full code, it will be helpful to understand program better
0
Can you suggest a solution to my problem