Packages

Packages #

Java packages are being used to group classes into one place. They are structured like folders. There are two types of packages in Java. The first one is build-in packages, like java.util.*, and the second ones are user defined packages.

Importing a Package #

Importing a package means importing all classes located in that package. To do that a * is placed after the last dot in the package. For example;

import java.util.*;

Importing a Class #

It is possible to import only one class. To do that after the import statement package path with class name is written. For example;

import java.util.Scanner;