1. Computing

Overloading

By

Definition:

Overloading is the ability to define more than one method with the same name in a class. The compiler is able to distinguish between the methods because of their method signatures.

Examples:

There are nine different ways the print method of the System.out object can be used:

 print.(Object obj)
 print.(String s)
 print.(boolean b)
 print.(char c)
 print.(char[] s)
 print.(double d)
 print.(float f)
 print.(int i)
 print.(long l)
 

When you use the print method in your code the compiler will determine which method you want to call by looking at the method signature. For example:

 int number = 9;
 System.out.print(number);
 String text = "nine";
 System.out.print(text);
 boolean nein = false;
 System.out.print(nein);
 

Each time a different print method is being called because the parameter type being passed is different. It's useful because the print method will need to vary how it works depending on whether it has to deal with a String or integer or boolean.

Glossary:

# A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Related Video
Create Bullet, Number, and Definition Lists in HTML
iDVD New Project
  1. About.com
  2. Computing
  3. Java
  4. Java Glossary
  5. O
  6. Definition for the Term: Overloading

©2014 About.com. All rights reserved.