To use classes with the same name in two different packages : import « Java Source And Data Type « SCJP






import java.util.*;
import java.sql.*;

public class MainClass{
   //Date date = new Date(); // error
   java.util.Date date = new java.util.Date();

}








1.4.import
1.4.1.You may import either an individual class from a package or the entire package.
1.4.2.White space and comments may appear before or after any of these elements.
1.4.3.To use classes with the same name in two different packages
1.4.4.Reference class without importing
1.4.5.Reference class with importing
1.4.6.Java compiler automatically imports all the classes in the java.lang package into every source file.