From the course: Java 8 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Organizing Java classes in packages

Organizing Java classes in packages - Java Tutorial

From the course: Java 8 Essential Training

Start my 1-month free trial

Organizing Java classes in packages

- Java developers typically organize their classes in packages. A package is a unique identifier that goes at the top of the class declaration. But it actually matches a folder hierarchy. As you've seen, you can create your Java classes in a project root folder, also known as the base package, but to keep your classes well organized, you should start with packages from the very beginning. I'm going to open this version of my Main class which is in the Packages folder. Packages is my project root and once again, I'll use a simple text editor. And I'm going to add a string at the top of the class declaration starting with the keyword package. Now, you can use any string you like as a package identifier but typically, they're formed from domains using reverse domain notation. So, if your domain is example.com, your package would start with com.example. and that would match your organization or company's domain but then you might add another string under that to make this unique to the…

Contents