How can I call a subclass out of another subclass, if the first class was initialized in the main class? It’s something like that:
public class main {
Sub1 test = new Sub1();
Sub2 test2 = new Sub2();
Sub2.bummer2();
}
Subclass 1:
public class Sub1 {
public static void bummer() {
System.out.println("got called");
}
}
The other subclass:
public class Sub2 {
public static void bummer2() {
//here i want to execute Sub1.bummer() without having to initialise it first
}
}
How can I do that?
Since it’s public and static, in Sub2 you can just call