You will need to create static methods, so you will need to do something like this:
public class A { public static void foo() { ... } }
And then you can call them like this:
public class B { ... A.foo(); }
Note, however, that static
methods must be self-contained.
EDIT: as recommended in one of the answers below, you can make it work like this:
package samples.examples public class Test { public static void A() { ... } }
And then do the following:
import static sample.examples.Test.A; public class Test2 { ... A(); }
source share