package in java is an encapsulation mechanism to group related classes and interfaces into a single module. The main objective of package is to resolve naming conflicts.

Example:

package com.java2learn.access;
class PackageDemo{
	public static void main(String[] args){
		System.out.println("Java2learn package Demo");
	}
}

Output:
p1














Here ‘.’ Represents current place.
The generated .class file will be placed in corresponding package structure.
If the required package structure is not already available this command itself create the needed packages.