Package in Java

A package is a namespace that organizes a set of related classes and interfaces.

Main Class in the named sample package. sample/

package sample;

public class Main {
    public static void main(String[] args) {
        System.out.println(" is in sample package");

Compile and Execute in command line

$ javac sample/*.java
$ java sample.Main is in sample package

Leave a Reply

Your email address will not be published.