java - variables and methods and actionlisteners -


i have (partially pseudo)code

class {   void b()   {     int d = 0;     jbutton c = new jbutton();     c.addactionlistener(new actionlistener() {       @override       public void actionperformed(actionevent e)       {         d = 1;       }     });   } } 

however, doesn't work, eclipse suggested adding final identifier d, makes value impossible change. sorry if it's stupid question, it's hard form question google this... can't declare variable on lever higher method b.

you want move declaration of d outside of method.

class {   int d = 0;    method b() {     jbutton c = new jbutton();     c.addactionlistener(new actionlistener() {     public void actionperformed(actionevent e) {       d = 1;     }   }  } 

..and format code.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -