declare variable as final

JComboBox bookmarkList;

String[] bookmarks = EmployeeEdit2.getBookmarks();

bookmarkList =new JComboBox(bookmarks);

bookmarkList.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

String selection = bookmarkList.getSelectedItem();

actionGoToBookmark(selection);

}

});

i am getting this error message when trying to compile this part:

"local variable bookmarkList is accessed from within inner class; needs to be declared final"

how do i declare it final?

thanks

[811 byte] By [boblettoj99a] at [2007-11-26 18:22:02]
# 1
final bookmarkList = new JComboBox(bookmarks);[url= http://java.sun.com/docs/books/tutorial/java/IandI/final.html]Writing Final Classes and Methods[/url]
Djaunla at 2007-7-9 5:55:55 > top of Java-index,Java Essentials,New To Java...
# 2
final JComboBox bookmarkListThat's it...
qbprogera at 2007-7-9 5:55:55 > top of Java-index,Java Essentials,New To Java...
# 3
and where abouts do i put that amongst the code?thanks :D
boblettoj99a at 2007-7-9 5:55:55 > top of Java-index,Java Essentials,New To Java...
# 4
final JComboBox bookmarkList;
hunter9000a at 2007-7-9 5:55:55 > top of Java-index,Java Essentials,New To Java...
# 5
> and where abouts do i put that amongst the code?> > thanks :DThe same place it is now.
hunter9000a at 2007-7-9 5:55:55 > top of Java-index,Java Essentials,New To Java...
# 6
Replace bookmarkList = new JComboBox(bookmarks);withfinal bookmarkList = new JComboBox(bookmarks);and read the link provided.
Djaunla at 2007-7-9 5:55:55 > top of Java-index,Java Essentials,New To Java...
# 7
> how do i declare it final?By declaring it final:String[] bookmarks = EmployeeEdit2.getBookmarks();final JComboBox bookmarkList = new JComboBox(bookmarks);kind regards,Jos
JosAHa at 2007-7-9 5:55:55 > top of Java-index,Java Essentials,New To Java...