空指针问题
import java.awt.*;import java.awt.event.*;
import javax.swing.*;
public class xing extends JFrame
{
private int xPoints[];
private int yPoints[];
private int i,j;
public xing() {
super("五角星");
int[] xPoints={75,87,129,93,103,75,47,57,21,63};
int[] yPoints={20,56,56,74,116,92,116,74,56,56};
this.setBackground(Color.darkGray);
this.setLocation(0,0);
this.setSize(300,250);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
public void paint(Graphics g)
{
g.setColor(Color.red);
for(i=0;i<9;i++)
{
j=i+1;
g.drawLine(xPoints[i],yPoints[i],xPoints[j],yPoints[j]);//这里有什么问题。总不能运行
}
}
public static void main(String args[])
{
new xing();
}
}