Java: Method overloading

This entry is part 19 of 54 in the series Learn Java

It is possible to declare multiple methods with the same name as long as the parameters vary in type or number.

It is a powerful feature that allows a method to handle a variety of arguments without the programmer needing to be aware of using different methods.

package javaapplication18;

public class JavaApplication18 {

    static class MyApp {

        void PrintOut(String s) {
        void PrintOut(int i) {

    public static void main(String[] args) {
        MyApp m = new MyApp();

So in the above example, we have 2 methods declared for PrintOut.  The first has a string argument and the second has an integer argument.


Series Navigation<< Java: Return statement
Java: Class >>