I have the following code in which I am looping through the rows of one array (composed of Strings) and copying it to another array. I am using .clone() to achieve this and it seems work as it changes the memory location of the rows themselves. I did notice that the String objects are still pointing to the same location in memory in both arrays but I won't worry about that for now, at the moment I just want to understand why the array I am cloning is not successfully assigning to the other array.
This is the incorrect line:
My code:
My compiler says: Required: T[]. Found: java.lang.String[]
Since ar[r] is an array and .clone() also returns an array why is this line incorrect.
I don't see where you are calling the copyMaze method, but you'll notice that it has a type parameter <T>. You'll need to make sure that you use <String> for that type parameter. If you don't know how to do that (which wouldn't be that unlikely given that you posted in Beginning Java) then show us the code which is calling copyMaze.
Actually the only place I wanted to use this method is in "mazeCopy" right bellow my maze declaration in the code I posted (It's the line that is commented out). I know it wouldn't make sense to have the parameter "ar" in this case since I can easily access all arrays I need, but I just wanted to test this out.