Java Reference
In-Depth Information
Import statement
In most object oriented programming language you may encounter the import statement. Im-
port statements are used to import source code of a class or package into another class. In
Java the keyword for import is “import”. In C# the keyword used in “include”. In some other
object oriented languages a different keyword for import may also be used. In Java, here is
the syntax:
Import <package>.<sub-package>.class_name
There could be many sub-packages nested inside their containing packages. It depends on
size of the packages and their branching into sub-packages.
What an import does is that it imports the source code from one class into another. So all the
source code from one class becomes available and for the compiler it looks like all the code
is written together.
Import of a class into another class is different from creating objects. By import you are just
getting the source code of a class. If you want to have objects from these classes then you
will have to create objects of these classes. Creation of objects is discussed in next section.
Search WWH ::




Custom Search