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 trialmema
4,373 PointsWhat is the point in using packages?
Hello,
So first of all i do understand the code that is being used in the video. But i do not understand why we created the package com.teamtreehouse ( i understand why it is named liked that). In the video Craig says it would help us to make our class names more distinguishable between other classes that we might be using. So could you please explain this to mean in greater detail.(A Example would be nice) And also what is meant by "access protection" and "name space management"?
So i hope you can help me understand the sense of using packages. Thanks in advance.
2 Answers
Jiří Kolařík
9,373 PointsHello, programming is about creating small functionality to independent package. You build program from small reusable blocks. The path/namespace of package grouping related functionality in objects and give them right name. This name can by same as in other packages and name space is solution to recognize them. The package shares only important "public" method for using it. And encapsulation (hide) "private,protected" method and variables which package needs for his own processing. You can know less part of package for his using. You have more easy work. In your project you can use many package from other projects without conflict in name(name space) or wrong using(encapsulation).
But understand all it, you need read more information from source: https://docs.oracle.com/javase/tutorial/java/concepts/ https://en.wikipedia.org/wiki/Object-oriented_programming
Durgaprasad Nagarkatte
1,861 PointsPackages might be pre defined classes or user built in classes which are helpful in solving many problems. For example while doing mathematical operations we import pre defined maths package for doing certain calculations.