How to get an instance of java.awt.Graphics in a java.applet.Applet?
问题 I am currently coding the game of Snake for my computer science class. However, I ran into a lot of difficulties (since I am the only one in my block that is working alone) and I had to restart. Right now I am just trying to make an array of objects (named Snake) from the second class (Segment) I made. I get a NullPointerException on line 26: g.fillRect(xValue, yValue, size, size); Where should I get an instance of Graphics to call this method on? import java.awt.*; import java.applet.*;