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 Java Data Structures Getting There Class Review

Java Packages

I'd like to know what exactly are we programming and what's the significance of domain, website, class order. I'm now quite sure what the example class is. Is it like the general world and treets = code for messages w/in that general world https://w.trhou.se/ar2dnlt8ef

1 Answer

Brendon Butler
Brendon Butler
4,254 Points

What you program in this course varies and jumps around quite a bit. I'm not really sure how to answer that question. But the whole package thing shouldn't be to hard to explain.

The standard naming convention for Java Packages can vary depending on your situation.

If you have a website (mine is www.sparkzz.net for example), you will want to take the reverse order of that website. net.sparkzz.www usually negating the "world wide web" unless that's what your project is. -> net.sparkzz.

This is in a dot notation format, in a standard file system format, it would look something like this net/sparkzz. net being the parent folder and sparkzz being the child folder. After this, usually you'd put the name of your project. Let's just say I have a project called "Super Pony Adventure," I would create another package nested under the sparkzz package, and I would name it "superponyadventure" or "spa" for short.

After all that is said and done, my package would look a little like this -> net.sparkzz.spa

This is the base package, where you would want to store your main class that contains your public void main(String[] args) method. If you need more organizations you can create even more packages under that spa package to hold all your neatly organized code.

This got a little long, and I got a little carried away. (don't steal my Super Pony Adventure game!) Hopefully this will give you a better understanding of Java Packages. If you have any questions please feel free to leave a comment! :D

note: packages are all lowercase whereas classes start with a capital letter.