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.

Comments

Popular posts from this blog

Develop an Android application to display “Hello World!” on screen

Program to design an applet which draws a circle (having color BLUE) inside a triangle (having color YELLOW)

Build a Simple Android App to Display Student Details