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/Main.java

package sample;

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

Compile and Execute in command line

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

Leave a Reply

Your email address will not be published.

ANOTE.DEV