Explain that Java’s return is like a platter where you can hand information between methods to help students create a concrete mental model for an often tricky subject.

  • Use the following metaphor to help students understand what happens to information that is returned in Java so they better understand how the keyword return functions.

    • When a method returns something in Java, tell students it puts what follows the return on a silver platter.

      • When you call a method, you are requesting that Java do some work and then put the fruits of that labor on a silver platter.

      • If you chose to store that information (like assigning it to a variable) the silver platter is delivered to your described location.

      • If the silver platter isn’t put anywhere in particular, it gets picked up by oom service (the Java Garbage Collector).

More about this tip

External Source

Interview with Serita Nelesen.