Join Peggy Fisher for an in-depth discussion in this video Using call by value and call by reference, part of Up and Running with Java.
- Most methods include parameters…as a way to pass values from the calling method.…There are two types of parameters:…call by reference and call by value.…The biggest difference is that the call by reference…allows the method and the calling program…to both point to the same address in memory…that contains the value of the variable.…So, changes made in method are reflected…back in the calling program.…The call by value makes a copy of the variable contents…so any changes made in the method…are not reflected back in the calling program.…
Let's look at a program that includes both,…call by value and call by reference.…This program computes the total meal plan cost…for a semester.…The main method calls four methods.…getTotalMealWeeks, getDailyMealCost,…compute the MealPlanCost, and finally…print the TotalMealPlan cost.…Let's take a look at each method.…I'm gonna scroll down you'll see the first method,…getTotalMealWeeks does not take anything…in the parentheses.…
There's no parameters.…But it is going to return the value…
- 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.