我想使用一个类(一种类型)中的静态方法,
以使调用通用.
有没有办法实现这个功能?一些伪代码有助于举例说明我正在尝试做的事情:
public class A
{
public static void aMethod1()
{
//do something
}
public static void aMethod2()
{
//do something else
}
}
public class B
{
public void bMethod(<Parameter that can take any of A's methods polymorphically>)
{
<call ANY method sent in by the parameter with the same line of code>
}
}
public class Main
{
public static void main(String[] args)
{
A obj_A = new A();
B obj_B = new …Run Code Online (Sandbox Code Playgroud)