package is standard inbuilt keyword of Java language. It is used to assign package (folder path) to any java class. In the above syntax pkg1, pkg2, pkg3—– pkgN are package names.
Whenever any class is assigned a package then it is necessary to keep that class file in the defined package.
In the above example awt is sub package present in the java package. package keyword will assign java.awt package to the class file in which it is defined.
import <pkg1>. <pkg2>————<class name >;
import is standard inbuilt keyword of java language. It is used to import single class file or multiple class files from different package to current package.
In the first syntax import keyword will import single class file and in the second syntax import keyword will import all the class files of given package.
import java.awt. *;
In the above example import keyword will import all the class files of the java.awt package.
In the above example, import keyword will import only Button class from the java.awt package.