j2me NullPointerException adding image to a vector
private Vector menuOptions;
void addOption(String imagefilename) {
try {
Image i = Image.createImage(imagefilename);
menuOptions.addElement((Object)i);
} catch (Exception e) {
e.printStackTrace();
}
}
And I'm getting: java.lang.NullPointerException at GraphicMenu.addOption(GraphicMenu.java:开发者_运维知识库31) //addElement line
Can I add a Inmutable images to a Vector Object?
Have you initialized the vector?
Vector menuOptions = new Vector();
精彩评论