Quick Index
Overview


This page is a biggie! 🔥

We've talked a ton about messages and we've coded methods. We're finally ready to send messages to objects! 😊

We left off our object construction work here.

We were able to:

  • Construct a Rectangle
  • Assign the object to a var "rec"

But how do we now send messages to the object?
Rectangle rec;

2
rec =
1
new Rectangle();

Menu Of Methods


We can't just randomly send a message "fooBoo" to an object.

We need to look at the menu of methods for the object type (Rectangle in this example).

In the previous chapter we coded these methods for Rectangle:


Selecting Method


Let's select the method "setSmall" for starters. We coded it here...

We're ready to send the message.

There is our message send highlighted.
Rectangle rec;
rec = new Rectangle();

rec.setSmall();

  • "rec" is the target object (i.e. the object we are sending the message to)
  • "setSmall" is the message we are sending

And the dot "." is the separator between the target and message name.

We might call the dot separator the dot operator.
1
rec.
2
setSmall();