Android Call an method from another class

后端 未结 4 577
生来不讨喜
生来不讨喜 2020-11-30 06:33

I know that this Question is repeated but I can\'t find the answer in Internet.

I want to call a method from another class.

I\'ve Class1 and Class2.

4条回答
  •  悲哀的现实
    2020-11-30 07:27

    You should use the following code :

    Class2 cls2 = new Class2();
    cls2.UpdateEmployee();
    

    In case you don't want to create a new instance to call the method, you can decalre the method as static and then you can just call Class2.UpdateEmployee().

提交回复
热议问题