且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何调用同一个包的另一个类中的方法?

更新时间:2023-11-18 18:18:46

创建 B 类的实例:

B b=new B();
b.method();

或者在B类中定义一个静态方法:

or define an static method in Class B:

class B
{
 static void staticMethod();
}

并这样称呼它:

B.staticMethod();