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 trialChristopher Jow
625 PointsOrder of methods, variables, modifiers, etc.
What is the property order for method, variables, modifiers, etc.? In the video, Craig has "final private string", but above it uses "public final string" or whatever. Just wanting to know what is the best order for things to be declared.
1 Answer
Steven Couture
2,106 Pointswhen wanting to make instance variables its best to declare them after opening the class block. by making something public final means it can be used outside the class but cannot be changed after being given a value (most likely from the constructor). When its private final, it can only be used in that class and cannot be changed after given a value (most likely from the constructor)
hope this helps, just comment if you need me to explain better!
Steven Couture
2,106 PointsSteven Couture
2,106 Pointsand no it doesn't matter what order its in and its better to do it after opening the class block
Christopher Jow
625 PointsChristopher Jow
625 PointsOk. Is there an order to those? Example: integers before strings or private before public.