Monday, 28 November 2016

Program to import package 'myPackage' and use the 'DisplayMsg' class in package

In previous program, we have crated a package named "myPackage" and added class "DisplayMsg" in that package. Now in this program we use that package to import the class "DisplayMsg" in class "PackageDemo".


PROGRAM
import myPackage.DisplayMsg;

class PackageDemo
{
 public static void main(String[] args)
 {
  DisplayMsg dm = new DisplayMsg();
  dm.show();
 }
}
OUTPUT
C:\>javac PackageDemo.java
C:\>java PackageDemo
This is from package.

No comments:

Post a Comment