Null pointer exception

I am new to java and would really appreciate some help. I am working on a form design to capture data and save it to a server where I can reload it and manipulate the data when required. I have designed the form and am able to save/reload it locally. The problem I am having is with a choice on my form. I have set up the correct criteria in init{

Choice details = new Choice() ;

details.addItemListener(this);

details.add("Option 1");

details.add("Option 2");

details.add("Option 3");

details.select(0);

add(details);

though when I attempt to read the selection using either position = details.getSelectedIndex(); OR detailsOutput = details.getSelectedItem(); in public void itemStateChanged(ItemEvent e)

I keep getting null pointer exception and cannot access the data, either as an int nor a string. In init I have used details.Select(0); but cannot understand where I am going wrong. My only previous programming experience was with pascal and cobol many moons ago, so my problem may be simple but I am losing more and more hair by the minute.

Much thanks in advance.

Jim

[1164 byte] By [jim@caledonia] at [2007-9-30 4:00:09]
# 1
If you catch the exception and make a printStackTrace(), you will the see the very line it occurs.
BIJ001 at 2007-6-29 17:31:01 > top of Java-index,Administration Tools,Sun Connection...
# 2
The problem is that details is a local variable declared in the init method. Problably this variable hides an instance variable with the same name.Try details = = new Choice() ;instead of Choice details = new Choice() ;
bartolomeo at 2007-6-29 17:31:01 > top of Java-index,Administration Tools,Sun Connection...
# 3
also try to look at source code of superclass, perhaps this helps.
GandulfKohlweiss at 2007-6-29 17:31:01 > top of Java-index,Administration Tools,Sun Connection...
# 4
Thanksthat worked :-)
jim@caledonia at 2007-6-29 17:31:01 > top of Java-index,Administration Tools,Sun Connection...