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.

package myPackage;

public class DisplayMsg
 public void show()
  System.out.println("This is from package.");

To compile the above package program use the following command.
javac  -d  .
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