• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

public final vs. final public

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just wanted to confirm this, I ran the test and it worked, but I just want to make sure that I didn't do something hokey that I didn't even realize. But can I interchange "final" and "public" in a public final declaration? just like static and public? In fact can I do that with all the scope modifiers? like private and protected with final and static?
 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can declare all modifiers in any order you want.But know different scenarios about what modifiers you can use for class & instance variables.For example you can't declare class as final abstract.
Veena
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Wilson Mui:
I just wanted to confirm this, I ran the test and it worked, but I just want to make sure that I didn't do something hokey that I didn't even realize.


Yes, you did something that is "hokey" but not illegal. The Java Language Specification suggests that modifiers should be used in the order that they appear in the JLS. Section 8.1.1 provides a good example.


If two or more class modifiers appear in a class declaration, then it is customary, though not required, that they appear in the order consistent with that shown above in the production for ClassModifier.


The exam won't test your knowledge of the suggested order.
[ May 08, 2003: Message edited by: Dan Chisholm ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic