A single-type import declaration imports a single type from a package.
It has the following form
import <fully qualified name of a type>;
The following import declaration imports the Employee class from the com.book2s.demo package:
import com.book2s.demo.Employee;
A single-type import declaration imports only one type from a package.
The following import declarations import Class11 from pkg1 package, Class21 and Class22 from pkg2 package, and Class33 from pkg3 package:
import pkg1.Class11; import pkg2.Class21; import pkg2.Class22; import pkg3.Class33;
The following code shows how to import Date class from java.util package.
import java.util.Date; class Main {/*from www . ja v a 2s . c om*/ public static void main(String[] args) { System.out.println(new Date()); } }
You can reference the class by using its full qualified name.
public class Main { public static void main(String[] args) { System.out.println(new java.util.Date()); } }