i wrote the following code :
public class Matrix
{
private final int[][] array;
private final int size1;
private final int size2;
Matrix(int size1,int size2)
{
this.size1=size1;
this.size2=size2;
this.array=new int[size1][size2];
}
Matrix(int[][] color)
{
this.size1=color.length;
this.size2=color[0].length;
this.array= new int[size1][size2];
for(int row=0;row<size1;row++)
{
for(int column=0;column<size2;column++)
{
this.array[row][column]=color[row][column];
}
}
}
}
public Matrix flipVertically()
{
Matrix newArray=new Matrix(array);
for(int row=size1-1;row>=0;row--)
{
for(int column=0;column<array[row].length;column++)
{
newArray[row][column]=array[size1][size2];
}
}
return newArray;
}
}
and my method needs to return a new Matrix which inside of it, the first row becomes the last row, the second row becomes the second last row and so on...
i wrote this code but i have 2 problems:
when i write
newArray[row][column]=array[size1][size2]
; it writes me : Matrix required but array found. why does it writes it? and how can i fix it?what does it means to return "Metrix" variable? how does it looks like?
Thank you !