Can static method access non-static instance variable?

后端 未结 5 2224
天命终不由人
天命终不由人 2020-12-16 19:31

So my understanding was that you can\'t use static method to access non-static variables, but I came across following code.

class Laptop {
  String memory =          


        
5条回答
  •  借酒劲吻你
    2020-12-16 20:04

    Static methods cannot modify their value. You can get their current value by accessing them with the reference of current class.

提交回复
热议问题