How to avoid this NullPointerException
问题 I'm working on a small arcade video game, and I am looking to double buffer to improve animation. I have one class that's supposed to draw the blank image, and another class that's supposed to draw a simple line. However, I keep getting a NullPointerException on the line where the line is supposed to be drawn class Render extends JPanel { public int dbWidth = 500, dbHeight = 400; public Image dbImage = null; public Graphics dbg; public void gameRender() { if( dbImage == null ) dbImage =