Program to create package named "myPackage" and put "DisplayMsg" class in it

In this program, we have created a package myPackage and put the DisplayMsg class in that package. Compile this program using java compiler then you will get a .class file in given package.


PROGRAM
package myPackage;

public class DisplayMsg
{
 public void show()
 {
  System.out.println("This is from package.");
 }
}
HOW TO COMPILE ?

To compile the above package program use the following command.
javac  -d  .  DisplayMsg.java
After successful compilation the myPackage directory will be created and the .class file is placed in that directory. The output of this program is the .class file.

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