Generally a single name space (memory) used which shared by all programs. This means that a unique name had to be used for each class to avoid name collision.
Some times there is a need to choose a same class name for more than one class. It is not possible to give two files with the same name and extension in the same directory, to avoid this problem java provides a mechanism for dividing the class name space into more manageable units. This mechanism is the package. The classes inside the package those are not accessible by the code outside the package. Class members can also be defined that are only exposed to other members of the same package. This allows classes to have sharing of knowledge of each other but not expose that knowledge to the rest of the world.
In Java, a package is a group of related types classes and interfaces which provides access protection and name space management to use those classes and interfaces.
Package is a mechanism for organizing a group of related files in the same directory. In a computer system , files are organized into different directories according to their functionality, usability and category. Package are containers for classes that are used to keep the class name space compartmentalized.
Java packages are classified into two types:
1. Java API Packages.
2. User Defined Package.
Java API Packages.
Java provides a large number of classes grouped into different packages according to functionality.
java.lang package
It provides a collection of language support classes and methods required for implementing basic features of Java.
These are the classes that compiler itself uses and therefore they are automatically imported.
They include classes for primitive data types, strings,math functions, threads,and exception.
java.util package
It provides a collection of language utility classes such as date & time, random calendar, vector, hashtable etc.
java.io package
It provides a collecton of Input output classes required for input/output manipulation.
java.net Package
It provides a collection of classes for networking. which provides communicating with other computers with local computers as well as Internet server.
java.awt Package
The abstract Window Tool Kit Package contain classes that implements platform-independents graphical user interface.They includes classes for windows , buttons, lists,menus and so on.
java.applet Package
It provides a set of classes that allows to create.Java applets.
Posted by : Ruchita Pandya
No comments:
Post a Comment