Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGlenn Wallace
3,701 Pointscannot assign a value to final variable characterName
Struggling with this one! Get this error when inputting /open PezDispenser.java into jshell. Anybody else run into this issue? Any help greatly appreciated. Thanks Glenn
1 Answer
alastair cooper
30,617 PointsHi
without your code, I can only guess, but it looks like...
The error message explains your problem. The variable is FINAL (ie can be set once only and is then immutable). Your code must be trying to reset it.
It is a long time since I did that module, but I think the name was set in the constructor. It is not possible to change it after that without removing the 'final' declaration from the variable
Glenn Wallace
3,701 PointsGlenn Wallace
3,701 PointsThanks for this Alastair, much appreciated, I will review my code.