aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes where inner classes go in source file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "where inner classes go in source file" Watch "where inner classes go in source file" New topic
Author

where inner classes go in source file

Pete Lyons
Ranch Hand

Joined: Aug 18, 2002
Posts: 109
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

Joined: Feb 26, 2001
Posts: 5288
    
  10

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.


Junilu - [How to Ask Questions] [How to Answer Questions]
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
 
subject: where inner classes go in source file