Thursday, January 26, 2017
Java packages
Java packages
Java Packages is the collection of pre-defined classes interfaces and thus all these classes contains both the implemented and non-implemented methods. Java is using java.lang package as the default package. Below are the list of some of the packages in java.
java.lang package
java.util package
java.io package
java.math package
java.rmi package
java.sql package
A java package is the collection of similar types. After Writing all the required pre-defined classes in java, those are being categorized in different categories and hence are termed as packages. For ex-
java.lang packages contains all the basic operations which are required for writing a simple java application and hence is the default package for any java class. Like that ,
java.io packages contains all the required classes and functionality for doing input and output operations using file and console.
As the java vendors has categorized the different classes in different packages, the same we can do while developing our own java application, which makes us to say that packages can be used to search and locate the classes and interfaces. Best practice is to always keep the classes in a packages which must be followed by three dots naming convention.
For ex- com.def.core ---> A package name , followed with three dots.
Note: Package must always be the first statement of any java class and can be only one package statement in each java file.
package is the keyword used before declaring any package name in the java source file.
For ex- package com.def.core.* ;
In the above statement .* indicate we are supposed to use all the classes defined in the com.def.core package.
Available link for download