• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where inner classes go in source file

 
Pete Lyons
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Sun Code Conventions and my book are unclear as to where inner class definitions go in the outer class's source file. I looked at the source for javax.swing.Timer, and it has one thrown in the middle of the methods - just below the method that uses it. I'm thinking I'll put my at the end of my source file after all the methods. Anyone have a definitive answer or at least a good argument one way or another? Personally, I find them to be distracting/confusing at the top of the file.
 
Junilu Lacar
Bartender
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not aware of any standard (but that doesn't mean that there isn't one). I would put it just above the method that uses it first. Now that might be just me and my Pascal background but I think that to be the most convenient.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pete,
I don't know if there is a convetion on where to place inner classes. As Junilu stated he likes to put them near their first use. I prefer putting them at the very end of the enclosing class definition. Just be consistent with whatever you choose to do.
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic