What is the proper way of accessing static fields in Java?

后端 未结 6 1482
面向向阳花
面向向阳花 2020-12-04 00:24

I just started learning Java and I wrote a class to test using static fields. Everything works fine but in Eclipse I see an icon which when hovered comes out as: \"The stati

6条回答
  •  北海茫月
    2020-12-04 00:57

    Static members should be accessed statically, i.e., ClassName.memberName. Non-static access is allowed though (objectName.memberName) but is discouraged.

提交回复
热议问题