AP® Computer Science A · Unit 3 · Topic 3.5
void Methods versus Methods That Return
Watch it explained
- How it worksHow does return hand a value back to the exact spot where the call was made?
- Worked exampleTrace a getArea call and find where its returned value lands in the calling statement.
- Common mistakeWhy doesn't any code written after a return statement ever get to run?
- Worked exampleFind what happens when a return sits inside an if inside a loop and the test passes.
Check yourself
Your turn1 of 2
A method contains: return total; System.out.println("done"); What happens to the println line?End of topic.