Join Peggy Fisher for an in-depth discussion in this video Introducing recursion, part of Up and Running with Java.
- The next topic we're going to review is recursion.…Recursion is the process of a method that calls itself…to solve a problem.…It can call itself again and again…to help break down a larger problem…to solve it in smaller steps.…Let's take a simple example.…When we want to print out a countdown…from 10 to 1, and then print the word Blast Off!…So in this example, we want to stop…when the number gets to zero.…Let's take a look at the program.…If we start with main on line 17,…you'll see that, on line 18, is a call…to the countdown method with a value of 10…as a parameter.…
That value is being passed to the countdown method,…into the variable called num.…So the first time in the method,…I have a value of 10.…If num==0, then I'm done, and I'm going…to print out the words Blast Off!…The first time through, num is not equal to 0,…so I go to the else portion of the statement,…and I print out the number.…So I'm printing out 10.…Then, I recursively call the method countdown.…It's important to note that you need to make sure…
- Downloading and exploring NetBeans
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Creating classes
- Sorting and searching arrays
- Manipulating files
- Handling errors
- Building GUIs
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Flow of Control
4. Classes and Objects
5. Beyond the Basics
6. File Manipulation
7. Graphical User Interface Basics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.