We need to remember one basic rule regarding accessing the static method in outer packages which is "Static methods should be accessed directly with class name"
If a class is accessible and if static method is accessible, i mean defined with correct access modifiers then that static method can be accessed anywhere within the project or ouside the project. See this example
public class ClassA {
public static void main(String[] args) {
display(); // calling without object
ClassA t = new ClassA();
t.show(); // calling using object
}
public static void display() {
System.out.println("Programming is amazing.");
}
public void show() {
System.out.println("Java is awesome.");
}
}
public class ClassB {
public static void main(String[] args) {
ClassA.display(); // calling without object
ClassA t = new ClassA();
t.show(); // calling using object
}
}