The difference between “public” and “public static”?

后端 未结 5 912
小鲜肉
小鲜肉 2021-01-30 06:58

What does static mean?

I know public means that it can be accessed from outside the class, and private only from inside the class…

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-30 07:17

    Static means that it can be accessed without instantiating a class. This is good for constants.

    Static methods need to have no effect on the state of the object. They can have local variables in addition to the parameters.

提交回复
热议问题