This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv 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 REST with Spring (video course) this week in the Spring 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: 24195

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?
I agree. Here's the link:
subject: importing
jQuery in Action, 3rd edition