Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

importing from same name packages

 
lajos kamocsay
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Costa lamona
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic