What is the difference between referencing a field by class and calling a field by object?

前端 未结 5 1951
渐次进展
渐次进展 2021-01-26 01:56

I have noticed that there are times when coding in Java that I have seen fields called by method:

System.out.println(object.field);

and

5条回答
  •  时光取名叫无心
    2021-01-26 02:19

    Refrencing a field by class requires the field to be static.

    Refrencing a field by object requires the field can be either static or non-static field .

提交回复
热议问题