Field access or method invocation operator:  .

Inside the class or interface, a field or a method of this class or interface can be accessed just by the name. But from outside the class or interface, the non-private field or method can be accessed using the dot (.) operator and:

  • If the field or method is non-static (instance member), the object name
  • If the field or method is static, the interface or class name
A dot operator (.) can be used to access a non-private field or method. If the field or method is static, the dot operator is applied to the interface or class name. If the field or method is non-static, the dot operator is applied to the object reference.

We have seen many such examples already. So, we just summarize all the cases ...

Get Introduction to Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.