- Have students think about two different types of notes, Notes That Make A Statement and Notes That Ask A Question, and how they are supposed to respond to each to help them understand the difference between void methods and methods that return something.
- Notes That Make A Statement - Notes that makes a statement do not need an answer.
- This type of note tells information to the receiver and the receiver does what they need to do with it.
- This note is never handed back.
- Notes That Ask A Question - A note that asks a question gets read by the person receiving it, then they write down an answer, then the answer is returned.
- This type of note gets handed back.
- The only way a return is worth anything is if the returned information is processed by the calling location (place asking the question).
- This means that you need to use the returned information.
- This means saving this information (as a variable) a lot of the time.
- Use the following example code to finish illustrating this point:
public void methodCall()
: Place where Note That Makes A Statement is received.methodCall();
: This is "passing" the Note That Makes A Statement.public String method2()
: Place where the Note That Asks A Question is received and where the answer is written back.String variable = method2();
: Place "passing" the Note That Asks A Question and saving the answer in a variable, variable.- Right side is "passing" the note with the question.
- Left side is grabbing the notecard with the answer on it back and reading/saving it.
- If you don’t grab the card and read/save it, all the work of passing the note and answering it went to waste.