Use class



examples/java/GreetingsA.java
class Greeting {
    public static void hello() {
       System.out.println("Hello World");
    }
}

public class GreetingsA {
    public static void main(String[] args) {
        System.out.println("Hello");
        Greeting.hello();
    }
}

javac GreetingsA.java
java GreetingsA


Hello
Hello World