Best rendering method using pure java?

Hello, i’m new here. I am very confused and curios.
If you’ll take a look over the internet for Java game programming tutorials you’ll find that people are teaching two common ways for rendering(in pure Java):

1.Using just an Image at the size of the window:


Image image = createImage(1024,768);
image.getGraphics().drawString("My string!",100,100);

2.Turning a BufferedImage into an Integer array for pixel manipulation:


BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
pixels[myPixel] = 0xFFFFFF;

I want to ask you which of them is better, and why? and if no, can you recommend me another method? I’m very curios about this and i want to develop my own game, but i’m still planning.