Skip to main content

Posts

Showing posts with the label Packages in Java | Java Package | How to implement Package in Java | Packages

Packages In Java

  Package in java is a group of similar type of classes, interface and sub-package. Packages in java can be defined in two ways which are 1 Built-in Packages 2 User-defined Packages Built-in Packages are       * Lang      * Util      * io      * awt      * net      * applet, etc. User-defined packages can be anything which are created by the user. Packages are nothing but container of the classes which store the no of classes, interface and their methods. Advantages of Packages 1 It provide access Protection 2 It removes the naming collision 3 it is used to categorize the classes and interface so that they can be easily maintained. Steps for creating a package Step-1 Create a folder in any drive of your choice  Step-2 example in d: package1 (it is the name of the package) Step-3 Open the java application and type the following code package package1; public class demo {  public void display() { System.out.println("Welcome to Programmingssidepoint"); } } Step-4 Sa