• Post Reply Bookmark Topic Watch Topic
  • New Topic

difference between package and import  RSS feed

 
dasari sudha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai

can any body tell me the difference between package and import statements like

import java.io.*;

can i give package jvav.io.*;

thanks in advance
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The single package line at the top of the file (must come before the imports and class) tells Java what specific package the class belongs to. Thus, "*" is inapplicable here since that's used to match all classes in a package during import. The package will also determine where Java will look for the class in the directory structure.

You use import to tell the Java compiler that your class needs to use other classes. You can import a single class per statement or all classes for a single package using "*".

I recommend starting with the Sun or JavaRanch tutorials to get up to speed quickly.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!