Here's an example of all three in one. Every Java program implicitly imports java.lang. However, if you import packages that contain multiple classes with the same name, you'll need to qualify their names explicitly throughout your code. For example, the photo. Java knows where to find them.
Variables are package by default unless declared public, private, or protected.
The files in a package are presumed to trust each other, and are usually implemented by the same person. Files outside the package can only see the public classes, methods, and fields. Before we knew about packages, we had to make the fields of DListNode public so that DList could manipulate them. Our list package above solves this problem by giving DListNode and its fields package protection, so that the DList class may use it freely, but outside applications cannot access it. In Homework 4, you'll see a slightly different approach.