Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Import Statement Question

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


But what exactly does it do ?
i tried to use List in the code and i got compiler error
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Prasad Kharkar ,

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic