Packages

import java.util.Scanner

//Here:
// java is a top level package
// util is a sub package
// and Scanner is a class which is present in the sub package util

A package as the name suggests is a pack(group) of classes, interfaces and other packages. In java we use packages to organize our classes and interfaces. We have two types of packages in Java: built-in packages and the packages we can create (also known as user defined package).

Advantages of using a package in Java: reusability, better organization, name conflicts.

Packages — Structure map

Clickable & Draggable!

Packages — Related pages: