So, I saw two ways to draw render.
CODE 1
private BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
private int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
Then in the render method,
for (int i = 0; i < pixels.length; i++) {
pixels[i] = 0;
}
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
CODE 2
private BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
In the render method,
g.drawImage(image, 0, 0, WIDTH, HEIGHT, null);
So what I basically want to understand is, what is the difference between the two and which one is better.
I know this is a very confusing question, but someone please help.