The method below goes through each row of the 2D array and checks if all elements of that array appear twice. If it does not, then it prints that row index. The problem with this code is that, it only checks first index of the 2D array, that's it. It should move to second index and start comparing that but it never does that. Why?
Major correction, to my own code and others. Very important concept when it comes to printing 2D arrays. I rather using while when there is a possibility I may not go through each row. My error was that I was not setting inner comparison integer's value to 0 so second turn it was already out of boundary and it was never getting checked again.
There is no such thing as a 2D array in Java®, only an array of arrays.
Please explain what you mean about each element appearing twice. None of your arrays contains all elements appearing twice. Particularly if you talk about appearing twice and you have a method called uniqueRows. What does the uniqueRows method do? The name is not specific enough. Does it count unique rows, or identify them, or print them?
If that is assigned work, you should correct its formatting and style in order to get good marks.
Your arrays have unhelpful names; why should an array be called c?
Make sure to leave empty lines between successive methods; line 17 is difficult to read because of that mistake.
It is not obvious what the variable cmpr means from its name.
Don't declare multiple variables on the same lin (line 19) and always put spaces around binary operators including =.
The fact that you are reinitialising your local variables in line 41 suggests you would have been better with a for loop. You can include the flag as part of the continuation condition:-
for (int i = 0; i < myArray.length && needsSearching; i++) ... That will keep the numbers' scope within the bounds of the loops, so you don't need to reinitialise them in line 41. You might be able to get the flag in the same scope, but I have never tried the following:-
for (int i = 0, boolean needsSearching = true; i < myArray.length && needsSearching; i++) ... I do not know whether such code will even compile.
Now, you will need to work out what the algorithm is to find the duplicates you are looking for. You can only do that on a sheet of paper, not on screen.
Edit: correct spelling mistake in underlined word.