Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Creating the MVP Remaining Tries

I 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 ?

Simon Coates
Simon Coates
28,692 Points

static makes something a class variable, rather than to be bound to an instance.

2 Answers

Henrique Voni
Henrique Voni
12,296 Points

Static 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
seal-mask
.a{fill-rule:evenodd;}techdegree
shekhar bhardwaj
Full Stack JavaScript Techdegree Student 12,373 Points

final 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.