Saturday, 6 January 2018

4.5 Package in Java

Package : It is a collection of similar type of classes.

syntax to create package : package packagename;

to compile it : javac -d . package_demo.java


package package_demo;

class package_demo
{
public void display()
{
System.out.println("Hello World");
}

public static void main(String args[])
{
package_demo obj=new package_demo();
obj.display();
}
}



to import a package :

import java.sql.*;

No comments:

Post a Comment