Join Peggy Fisher for an in-depth discussion in this video Understanding overloaded methods, part of Java Essential Training for Students.
- View Offline
- Exercise Files
- Sometimes when writing your programs…you might want to create the same method twice,…but with slightly different values as arguments…or maybe even a different return type.…Two or more methods may have the same name…as long as the list of parameters or arguments…or the return type is different.…When this happens it's called Overloading.…You Overload the method.…For example, if you want to write a method…that finds the average of three numbers…you might want to allow it to use three integers,…but you also might want to allow it to use three doubles.…
The logic is the same but the type of data…sent by the calling program is different.…So you would create two methods with the exact same…return type and the exact same name…but they would each have different arguments.…One would have three INTS and one would have three doubles.…Again, this is called method Overloading.…Now let's take a look at the example I have here.…I have updated the program we worked on the last section…to calculate the total amount of groceries.…
- Getting started with parsing
- Reviewing data types
- Using decisions
- Creating user-defined methods
- Command-line debugging
- Exploring the Java API
- Creating and instantiating classes
- Working with interfaces
- Storing items with arrays
Skill Level Intermediate
1. Command Level Programming
2. Basics Review
4. Java API
5. Simulations and Algorithm Analysis
6. Classes and Objects
7. More on Classes
8. Data Structures
- 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.