• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

Please advise on physical order of Java items

Dear Experts,

Could you folks either tell me directly, or point me to links on the best practices for the physical order of items within a class?

At the moment, I'm trying to place abstract method declarations.  But I'd like to know the whole ball of wax.  I've read that all public methods should come first, for instance.  But should they come before private class variables?  Should your constructor/s always come first?   Etc., etc....

Thanks!
BrianMc1958
0
BrianMc1958
Asked:
BrianMc1958
  • 4
  • 2
2 Solutions
 
CEHJCommented:
I don't think there are hard and fast rules and i wouldn't bother yourself overmuch with it. Imitating Sun's source (usually) is a good example
0
 
ellandrdCommented:
When i was learning Java I was told to place all my and imports and variable declarations at the top and in groups.  then followed constructor classes, public first, then private and last i had my methods at the bottom half of my program.

here is a nice article about coding structure - its worth a coffee break and a read...

http://www.webcom.com/~haahr/essays/java-style/structure.html

ellandrd
0
 
ellandrdCommented:
sorry - i cant type to save my life today.

When i was learning Java I was told to place all my imports and variable declarations at the top and in groups.  then followed my constructors, public first, then private and last i had my methods at the bottom half of my program.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
BrianMc1958Author Commented:
Nice link!
0
 
ellandrdCommented:
;-)

ellandrd
0
 
ellandrdCommented:
Thanks for the grade

ellandrd
0
 
CEHJCommented:
:-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now