aspose file tools*
The moose likes Associate Certification (OCAJP 7/8) 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
JavaRanch » Java Forums » Certification » Associate Certification (OCAJP 7/8)
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: 42608
    
  65
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 - my free Android networking tools app
Mustakimur Rahman
Greenhorn

Joined: Oct 12, 2013
Posts: 13

Thanks to you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: import class from different package with same name