A package is a way of grouping related Java classes, interfaces, and other types together.
It also provides a namespace to avoid naming conflicts.
Example:
package com.example.app;
Then the class belongs to that package.
Main reasons:
Example:
com.company.model
com.company.service
com.company.controller
import allows you to use a class from another package without writing its full package name.
import java.util.ArrayList;
ArrayList<Integer> list = new ArrayList<>();
Without import: