Forums Register Login
Import Statement Question

But what exactly does it do ?
i tried to use List in the code and i got compiler error
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.
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
thanks Prasad Kharkar ,

Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 486 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 22, 2018 13:35:47.