package com.company.MyFirstProgect; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; public class Main { public static void main(String[] args) throws IOException { File file = new File("C:\\Users\\kuhaj\\Downloads\\image1.png"); File file1 = new File("C:\\Users\\kuhaj\\Downloads\\image2.png"); BufferedImage image1 = ImageIO.read(file); BufferedImage image2 = ImageIO.read(file1); int columns = image1.getWidth(); int rows = image1.getHeight(); for (int row = 0; row < rows; rows++) { for (int col = 0; col < columns; col++) { int rgb = image1.getRGB(col, row); int rgb2 = image2.getRGB(col, row); if (rgb != rgb2){ System.out.println("NO!!!!!"); } } } } } When image1 and image2 different, this code still considers them the same and does not output NO!!!!! What is the problem?
rows++, but should berow++- Regent