Given an n × n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
class Solution {
    public int[][] flipAndInvertImage(int[][] image) {
        for (int i = 0; i < image.length; i++) {
            for (int j = image[0].length - 1; j >= 0; j--) {
                image[i][j] ^= 1;
                System.out.printf("%d ", image[i][j]);
            }
        }
        return image;
    }
}
This is my approach but when I return the 2D array not getting the desired output but you can see the stdout is printing result. May I know where I am going wrong

 
     
    