This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes importing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "importing" Watch "importing" New topic


Atrus Greyor
Ranch Hand

Joined: Mar 07, 2004
Posts: 110
do you have to import each section of the API indivdualy?
For example instead of:
import java.awt.*;
import java.lang.*;
couldn't you just do:
import java.*;
Thanks in advance!
Wai Hung

Joined: Apr 15, 2004
Posts: 23
I don't think you can do that
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24190

Despite appearances, a package x.y is not, in any meaningful sense, "part of" a package x. "import x" imports only classes directly in package "x", not those in "x.y". Since there actually are no classes in the "java" package, the answer is no, "import java.*" does nothing useful.

[Jess in Action][AskingGoodQuestions]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
I'm thinking that Ernest might have meant to say:
"import x.*" imports only classes directly in package "x", not those in "x.y"

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
walter kirsch

Joined: May 10, 2004
Posts: 1
Then, will
import "java.*.*"
do the trick?
Have you checked out Aspose?
subject: importing
It's not a secret anymore!