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 trialShanu Agarwal
Courses Plus Student 700 PointsI have a doubt that about static with final
Why are we using static with final in MAX_MISSES variable ? Is only final not enough to make MAX_MISSES constant ?
2 Answers
henriquegiuliani
12,296 PointsStatic means that the MAX_MISSES property is a class property. Making it static lets you handle some logic when a object from that class is created.
shekhar bhardwaj
Full Stack JavaScript Techdegree Student 12,373 Pointsfinal indicates that the value of the variable won't change - in other words, a variable who's value can't be modified after it is declared. Use public final static String when you want to create a String that: belongs to the class (static: no instance necessary to use it), and that won't change (final), for instance when you want to define a String constant that will be available to all instances of the class, and to other objects using the class.
Simon Coates
28,694 PointsSimon Coates
28,694 Pointsstatic makes something a class variable, rather than to be bound to an instance.