14-recursion - Recursion CSE 114: Computer Science I SUNY...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Recursion CSE 114: Computer Science I SUNY at Stony Brook 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Software Reuse Laziness is a virtue among programmers Often, a given task must be performed multiple times Ex. loops for local repetition Instead of (re)writing the code each time, it is more efFcient to write the code once and reuse it as necessary 2
Background image of page 2
Methods A function is a small block of code that can be called from another point in a program In Java, functions are called methods Functions/methods enable reuse, and can be used to abstract out common tasks Ex. computing the tax on a purchase Method results can be changed by supplying different input values 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Only one method can be active at a time If a method is invoked, the calling method is put on hold while the new method executes. When the called method completes (returns), execution returns to the calling method A method may call other methods. Method calls can be nested. Ex., A calls B, which calls C, etc.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 10/22/2011.

Page1 / 19

14-recursion - Recursion CSE 114: Computer Science I SUNY...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online