J2EEOnline J2EE






Java Fundamentals  «Prev 
Java Packages

Prepending Package Name

The classes and interfaces of other packages can be accessed by prepending their package name.
For example, to access the Vector class of the java.util package, you could refer to it as java.util.Vector as in the following example:
A package is a collection of classes with a related purpose and all classes in the standard library are contained in packages. The Rectangle class belongs to the package java.awt (where awt is an abbreviation for "Abstract Windowing Toolkit"), which contains many classes for drawing windows and graphical shapes.
Java classes are grouped into packages. Use the import statement to use classes that are defined in other packages.


java.util.Vector v = new java.util.Vector(); 
The problem with using the package name is that it adds a lot more text to your code. I recommend that you import the java.util package (at the top of the file) instead of prepending java.util whenever you reference a class or interface of this package