aspose file tools*
The moose likes Java in General and the fly likes importing from same name packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "importing from same name packages" Watch "importing from same name packages" New topic
Author

importing from same name packages

lajos kamocsay
Ranch Hand

Joined: Aug 12, 2006
Posts: 37
Hello,

I'm trying to import the following method:

org.jdom.output.Format.getPrettyFormat()

But there's already a package called Format imported (java.text.Format).
Is there a way to import this method, or should I just type the full name?

Thanks,
Lajos
Ramen Chatterjee
Ranch Hand

Joined: Apr 27, 2006
Posts: 62
Hi

You will need to import both (using package wildcards or fully qualified names), and then use the fully qualifed name when you declare/initialise your variables.

HTH

Ramen


Could try harder
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

You will need to import both (using package wildcards or fully qualified names), and then use the fully qualifed name when you declare/initialise your variables.

No - if you use fully qualified names when you declare your variables, you do not need to import them.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Costa lamona
Ranch Hand

Joined: Sep 24, 2006
Posts: 102
You can import one package, and then use full name for the other class

and if it is java 5 and it is a static method you can use static imports

but I donot recommend static imports because it makes code unreadable.


SCJP 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: importing from same name packages
 
Similar Threads
Static keyword Doubt
Can we extend multiple classes ?
Method visibility inside a try block
Supress call from super keyword with powermockito
using classes in jsp (not servlets )