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();
}
}
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