O'Reilly logo

Java Quick Syntax Reference by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 14

image

Packages and Import

Packages are used to avoid naming conflicts and to organize code files into different directories. So far in this book the code file has been located at the root of the project’s source directory. Therefore, it has belonged to the so called default package. In Java, the directory a file belongs to, relative to the project’s source directory, corresponds to the package name.

To assign a code file to a package, for example “mypackage”, it must be moved to a folder by that name, under the project directory. Furthermore, the file must specify which package it belongs to by using the package keyword followed by the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required