Krivalar Tutorials 
Krivalar Tutorials

Java Packages


<<Previous

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>;
Example:
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:

programming.java.keywords;

package is declared as:

package programming.java.keywords;

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

/programming/java/keywords

This package can be imported by other classes as:

import programming.java.keywords.*;

This will import all the classes and interfaces inside the package programming.java.keywords

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.io
  • java.sql
  • java.util
  • java.net
  • java.awt
  • java.lang.reflect
  • java.nio
  • javax.ws.rs
  • 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
  • com.google.common.annotations


<<Previous

Next >>





















Searching using Binary Search Tree