Course Content‎ > ‎Session 5‎ > ‎

Basic Java Packages

One of the main features of OOP is its ability to reuse the code already created.  One way of achieving this is by using the classes from other programs, without physically copying them into the program you are currently +creating. This concept in Java is called as packages, while in other languages is called as class libraries. Packages are a way of grouping a variety of classes and/or interfaces together. The grouping is done according to the functionality. Therefore we can say packages act as containers for classes. By organizing our classes into packages we can achieve following benefits:
The classes of other programs contained in the packages can be easily used.
In packages, classes can be unique compared with classes in other packages i.e. two classes in two different packages can have the same name.  They may be referred by their full name comprising of the package name and the class name.
Packages provide a way to hide classes.
Packages also provide a way for separating design from coding.
In Java packages are classified into two types:
    1. Java System packages (examples below)
    2. User-defined packages (next section)
Java System packages: Java system provides a large number of classes grouped into different packages according to the functionality. In a Java program, we use the packages available with the Java system. Here are few commonly used packages:

 java.appletProvides the classes necessary to create an applet and the classes an applet uses to communicate with its applet context.
 java.awtContains all of the classes for creating user interfaces and for painting graphics and images
 java.beansContains classes related to Java Beans development
 java.ioProvides for system input and output through data streams, serialization and the file system
Provides classes that are fundamental to the design of the Java programming language
 java.mathProvides classes for performing arbitrary-precision integer arithmetic (BigInteger) and arbitrary-precision decimal arithmetic (BigDecimal)
 java.netProvides the classes for implementing networking applications
 java.rmiProvides the RMI package 
 java.securityProvides the classes and interfaces for the security framework
 java.sqlProvides the JDBC package
 java.textProvides classes and interfaces for handling text, dates, numbers, and messages in a manner independent of natural languages
 java.utilContains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).