JAVA : Accessing static method properly

后端 未结 5 1102
既然无缘
既然无缘 2021-01-05 02:40

I am new to JAVA, and I like to try and understand everything.

When accessing a static method \"hero.returnHp()\" in JAVA, I have the following:

 he         


        
5条回答
  •  星月不相逢
    2021-01-05 03:26

    static means a static way. One reason to use static is you can access it using class directly. that is its benefit. that is why main is always static. The entrance function don't need to create an instance first. Actually if you search static in google, and understand it deeply. U will know when and why use static.

提交回复
热议问题