I'm aware that arrays are objects and in java objects are transfered by reference which could cause aliasing so objects should be returned with in this form to not cause aliasing:
return new (object(parameters));
So this is what I'm trying to do with multidimensional arrays, however for some reason compiler says I have an error : "array dimension missing".
public int[][] Testing(int[][]arr)
{
int[][]newArr=new int[arr.length][arr[0].length];
for(int i=0;i<arr.length;i++)
{
for(int j=0;j<arr[0].length;j++)
{
newArr[i][j]=arr[i][arr[0].length-1-j];
}
return new int[][]newArr;
}
}
Could anyone tell me how to return in a method an multidimensional array without aliasing?
Thank you.