If you really want or need to use the same class name from two different packages, you have two options:
1-pick one to use in the import and use the other's fully qualified class name:
import my.own.Date;
class Test{
public static void main(String[] args){
// I want to choose my.own.Date here. How?
//Answer:
Date ownDate = new Date();
// I want to choose util.Date here. How ?
//Answer:
java.util.Date utilDate = new java.util.Date();
}
}
2-always use the fully qualified class name:
//no Date import
class Test{
public static void main(String[] args){
// I want to choose my.own.Date here. How?
//Answer:
my.own.Date ownDate = new my.own.Date();
// I want to choose util.Date here. How ?
//Answer:
java.util.Date utilDate = new java.util.Date();
}
}