Krivalar Tutorials 
Krivalar Tutorials

Java Packages


Next >>

In Java, packages are similar to directories in UNIX or folders in Windows. Package names are conventionally expressed as lower case letters. A package is declared as shown below:

package <package-name>;
package programming;

A package can have sub-package and so on. Hierarchy of packages are expressed separated by dots. If package programming has a sub-package named java and if the subpackage java has a further subpackage named keywords, then the package keywords is expressed as:;

package is declared as:


The classes to be placed in "keywords" needs to be placed inside the directory structure


This package can be imported by other classes as:


This will import all the classes and interfaces inside the package

Packages in JDK

Java Development Kit (JDK) has several packages that are used imported in the classes you write. The popular packages used are:

  • java.lang
  • java.math
  • java.sql
  • java.util
  • java.awt
  • java.lang.reflect
  • java.nio
  • javax.xml.soap
  • javax.servlet
  • javax.swing

There are thousands of third party java libraries available in the market available as free and open source. Some of those are:

  • org.junit
  • org.slf4j
  • org.apache.commons.logging


Next >>

Searching using Binary Search Tree