What is it and what is the function. (dot) in OOP?

4

A long time ago a teacher defined and explained the function of . in POO (Java Classroom).

In time I forgot, but I found it quite interesting, we often think it's just a "dot", but it's not quite like that.

So the question: O que é e qual a função . (ponto) em POO?

    
asked by anonymous 24.02.2016 / 13:36

2 answers

8

It is a binary operator (it has two operands, one on the left side and one on the right side). Usually called dot operator .

The most common thing is that on the left side is the object you are referencing. On the right side is the message that is passing to the object. The most common is to be invoking a method, but it can also be direct access to an object variable. So it is the access operator to members of an object.

There are cases where access is not made to the object, but directly to the class.

You can also use the package name separator, but this is not so closely related to the focus of the question.

Documentation .

    
24.02.2016 / 13:47
5

Do you mean dot operator?

According to the Java Tutorial available in this link . The point is for:

  

Code that is outside the object's class must use an object reference or expression, followed by the dot (.) operator, followed by a simple field name ...

Free translation:

  

External object code needs to use an object or expression reference, followed by the dot operator ...

I hope I have helped.

    
24.02.2016 / 13:42