B
budianermayi
Unregistered / Unconfirmed
GUEST, unregistred user!
我的一个程序:
import java.awt.*;
public class awtimage {
public void themain(){
Image theimage ;
Graphics theGraphics = null ;
Frame f = new Frame("ok");
f.setSize(300,300);
theimage = f.createImage(100,100);
theGraphics = theimage.getGraphics();
theGraphics.fill3DRect(10,10,200,200,true);
f.pack();
f.setVisible(true);
}
public static void main(String[] oo){
awtimage a = new awtimage();
a.themain();
}
}
编译通过,可是在运行时出错:
exception in thread main java.lang.Nullpointerexception...
import java.awt.*;
public class awtimage {
public void themain(){
Image theimage ;
Graphics theGraphics = null ;
Frame f = new Frame("ok");
f.setSize(300,300);
theimage = f.createImage(100,100);
theGraphics = theimage.getGraphics();
theGraphics.fill3DRect(10,10,200,200,true);
f.pack();
f.setVisible(true);
}
public static void main(String[] oo){
awtimage a = new awtimage();
a.themain();
}
}
编译通过,可是在运行时出错:
exception in thread main java.lang.Nullpointerexception...