Monday, 28 November 2016

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.

No comments:

Post a Comment