I am having trouble with this code:
package shapes;
import java.awt.Graphics2D;
import javax.swing.JFrame;
public class Shapes extends JFrame {
public static void main(String[] args) {
doDrawing();
}
private static void doDrawing() {
Graphics2D g = null;
// TODO Auto-generated method stub
Graphics2D g2d = (Graphics2D) g;
g2d.drawLine(20, 20, 100, 100);
}
}
But when i run it i get:
Exception in thread "main" java.lang.NullPointerException
at shapes.Shapes.doDrawing(Shapes.java:17)
at shapes.Shapes.main(Shapes.java:10)
How shall i fix this problem?