my dog learned polymorphism*
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
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: 1526
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: 1526
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>;
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: import packages?
Similar Threads
classpath issue
include class in other file?
Document to String
ODBC and xBase
WA #1.....word association