Calling static method from another java class

前端 未结 3 1565
执笔经年
执笔经年 2020-11-28 15:14

I\'ve recently switched from working in PHP to Java and have a query. Want to emphasise I\'m a beginner in Java.

Essentially I am working in File A (with class A) a

3条回答
  •  隐瞒了意图╮
    2020-11-28 15:22

    You don't need to create an instance of the class to call a static method, but you do need to import the class.

    package foo;
    
    //assuming B is in same package
    import foo.B;
    
    Public class A{
      String[] lists = B.staticMethod();
    }
    

提交回复
热议问题