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 trial

Java

Task 1 of the Class Review challenge- ordering of package and import statements

Hi everyone,

On the first task of the challenge: "Add declarations for private member fields for author, title, body, category, and creation date. The date should be of type java.util.Date (make sure you import it)."

I instinctively went to add the line that imports java.util.Date, and placed it on the top line.

I get now that I was thinking of the ordering in terms of imports (Craig mentioned that the general ordering of imports is to have those statements containing java at the top), and that I didn't see that the existing line (which I moved down to the second line) is the package declaration.

However, what is the actual reason that packages go at the top? I feel like being very early in the data course this will become apparent later on, and it feels intuitive I guess (being a line that sets out where the class 'lives'?) but I'm a little curious now.