0
Nested for-loop.
I'm trying to initialize an array from an object I'm creating. However, I keep getting this error message: /Squarelotron.java:21: error: incompatible types: int cannot be converted to int[][] int[][] ring = squarelotron[x][j]; ^ Why, then am I getting this error? Here's a link to my code: https://code.sololearn.com/c9VypHQF73P8/#java. According to the compiler, the error is on/starts from line 22. Any assistance would be very much appreciated.
5 ответов
0
You are trying to initialize a 2D array with "a single element" of a 2D array.
0
So that means that squarelotron[x][j] is a single element?
0
Yes.
squarelotron is an array.
sauarelotron[x][j] is a single element.
0
Alright. I thought the loop would initialize the array with the first row of squarelotron[][].
I'll try initializing it the long way round and see if that brings good results.
0
But ultimately, my goal was to create a ring taking the first and last rows of squarelotron and the values along the side (imagining the squarelotron as a matrix might help you understand what I'm saying).