Java: Calling a static method in the main() method

前端 未结 4 1928
夕颜
夕颜 2020-12-11 09:19

I am supposed to do the following:

Write a Java application (Client) program with a static method called generateEmployees( ) that returns a random list

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 09:33

    It's a static method, so ... it does not need to be accessed within the context of an instantiated object. You can just, you know, call it from your public static void main(...) method. If the class that contains your main() method is named Employee, then...

    Employee.generateEmployees(); 
    

    would do the trick.

提交回复
热议问题