File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes import packages? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "import packages?" Watch "import packages?" New topic

import packages?

Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1599
Can import statement import a package or only classes?

Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
you can import both packages as well as a specific class from a specific package

the general syntax is import <package-name>.*; //import all classes
//only classes are imported
//sub packages are not imported.
//you need to writes seperates statments if you want
//to import the sub packages to

import <package-name>.<class-name>; //import a class

SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1599
In a mock test i had statement.
import <pacakgename> ;

with no dot star (.*) after it.
Purujit Saha
Ranch Hand

Joined: Nov 01, 2005
Posts: 86

Akhil Trivedi

import <pacakgename> ;

with no dot star (.*) after it.

This is error.
We can use import statement as,
1) import <pacakgename> . *;
2) import <pacakgename> . <classname>;
I agree. Here's the link:
subject: import packages?
jQuery in Action, 3rd edition