jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Import Statement Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Import Statement Question" Watch "Import Statement Question" New topic
Author

Import Statement Question

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634



But what exactly does it do ?
i tried to use List in the code and i got compiler error


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

It would import classes under the java package, if there were any. It's not recursive. List is under java.util, so it won't be found.


[My Blog]
All roads lead to JavaRanch
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 438

I will elaborate what christophe has said

suppose you have a package called packageA and you have classes classA, classB, ClassC in that package
and you have another package called innerpackage that is in the packageA
and the contents of the innerpackage are innerclassA, innerclassB

and you have another class where you are importing some packages

so when you write
import packageA.*;

you are importing only classes provided in the packageA i.e. classA ,classB, and classC
the innerpackage classes are NOT imported

for importing them
you have to write specifically

import packageA.innerpackage.*
now your innerclassA and innnerclassB will get imported

hope this helps
happy preparation mohit

SCJP 6 [86%] June 30th, 2010
OCPWCD [84%] March 26th, 2013
If you find any post useful, click the "plus one" sign on the right
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

thanks Prasad Kharkar ,

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Import Statement Question
 
Similar Threads
what will happen if we import a package twice
import problem
Exclusively Swing
creating a package
import static question