Join Peggy Fisher for an in-depth discussion in this video Overloading functions, part of Learning Java.
- Two or more methods may have the same name…as long as the list of parameters…or the return type is different.…When this happens it's called overloading.…For example, if you wanna write a method…that finds the average of three numbers…you might wanna allow it to use…three integers or three doubles.…The logic is the same,…but the type of data sent by the…calling program is different.…Let's take a look.…Let's start by adding a method…that takes three integer parameters.…My method's gonna be public, static.…
I need to return the average, which will be a double.…The name of my method will be average…and it takes three integers.…Int x, int y and int c.…Inside my method I wanna calculate the average…and return it to the calling program.…Remember, since x, y and z are integers values…I need to change the answer, so I get a double.…So I can do that using either…implicit or explicit conversion.…I'm gonna use implicit conversion.…
Return.…I need to first add the values x + y + z,…then I can divide that by 3.0.…Remember, if I divide by a double…
- 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.