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 trial

Java Java Objects Harnessing the Power of Objects Constants

Alex Read
Alex Read
991 Points

How come final is used after public in a 'public' variable, but before 'private' in a private variable?

I just wondered why 'final' is used before 'private' when defining a private var, but after 'public' when defining a public var? Thanks ;)

1 Answer

Philip Schultz
Philip Schultz
11,437 Points

Hey Alex, I had the same question, but I started playing around with it in jshell. It seems it doesn't matter which is before the other. Are you finding the same thing to be true? I found this stackoverflow conversation about it. It seems as though it technically doesn't matter, however there is a recommended guideline.

proper guidelines : public protected private abstract default static final transient volatile synchronized native strictfp

https://stackoverflow.com/questions/16731240/what-is-a-reasonable-order-of-java-modifiers-abstract-final-public-static-e

Alex Read
Alex Read
991 Points

Oh yeh just had a look! Thanks for the answer really helped me out