In this video, Kathryn explains the difference between call by value and call by reference. In Java, there is only call by value, and Kathryn walks through an example, referencing the Car class built in previous videos, to show you exactly how this works.
- [Instructor] Call by value and call by reference…are concepts involved with passing an argument…into a function call.…However, before we jump into this,…let's review the difference…between an argument and a parameter.…An argument is the actual value…that gets passed into the function.…For example, let's say we had a method defined…called changePaintColor.…When we call this method,…we would need to give it a paint color.…The paint color we give it is called an argument.…In this example, the paint color is red…so red is the argument.…
A parameter is an input variable and a method definition.…Looking at how changePaintColor is defined,…color is a parameter…that allows us to pass the new paint color…to the changePaintColor function.…Color is defined as a string in the method's definition…making it a parameter.…So what happens when we call a method?…When we call a method, the parameter or parameters…get the value of the argument or arguments…passed to the method itself.…Now that we understand the difference…between an argument and a parameter,…
- Downloading Java 9 and choosing an IDE
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Working with inheritance and interfaces
- Learning lambda
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Control Flow
4. Beyond the 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.