Packages in Java

What are Pacakges in Java ?
Use of Packages :
How to create a package ?
How packages work?
Package naming conventions :
Adding a class to a Package :
Subpackages :
import java.util.*;
// util is a subpackage created inside java package.
Accessing classes inside a package
// import the Vector class from util package.
import java.util.vector; 

// import all the classes from util package
import java.util.*; 
// All the classes and interfaces of this package will be accessible but not subpackages.
import package.*;

// Only mentioned class of this package will be accessible.
import package.classname;

// Class name is generally used when two packages have the same class name.
// For example in below code both packages have date class.
// So we need to use a fully qualified name to avoid conflict
import java.util.Date;
import my.packag.Date;

Types of Packages

1. Built-in Packages
2. User Defined Packages
Using Static Import
// Note static keyword after import. 
import static java.lang.System.*; 
   
class StaticImportDemo { 
   public static void main(String args[]) {       
        // We don't need to use 'System.out' as imported using static. 
        out.println("GeeksforGeeks"); 
   } 
} 

Output:

GeeksforGeeks