File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Associate Certification (OCAJP 7) and the fly likes import class from different package with same name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Associate Certification (OCAJP 7)
Bookmark "import class from different package with same name" Watch "import class from different package with same name" New topic
Author

import class from different package with same name

Mustakimur Rahman
Greenhorn

Joined: Oct 12, 2013
Posts: 13

When I try this:

I found some compiler error as they both import same class name.
But, when I tried:

It does not show me any error.
Why it does not show any error thought in this time I try to import two class with same name?
Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
In the second case the compiler will assume that whenever you refer to "Date" throughout your code, you mean java.sql.Date because that's the one you explicitly imported.

In the first case it gets confused because you're explicitly importing both.

The usual workaround is to import explicitly one of them (maybe the one that's used more often), and refer to the other always by its fully qualified class name.


Ping & DNS - updated with new look and Ping home screen widget
Mustakimur Rahman
Greenhorn

Joined: Oct 12, 2013
Posts: 13

Thanks to you.
 
 
subject: import class from different package with same name
 
Similar Threads
Help need with import file in Netbeans
Date issue
package
How to import 2 classes with same name
Java class duplication