Last active
June 13, 2017 20:15
-
-
Save raikusy/996c6b304f1f082042356b6ed41f9d44 to your computer and use it in GitHub Desktop.
Method Overloading in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Over | |
{ | |
public void add(int x, int y) | |
{ | |
int sum = x + y; | |
System.out.println("Sum of integer numbers: " + sum); | |
} | |
public void add(float x, float y) | |
{ | |
float sum = x + y; | |
System.out.println("Sum of float numbers: " + sum); | |
} | |
public void add(int x) | |
{ | |
System.out.println("Single integer number: " + x); | |
} | |
} | |
public class Loading | |
{ | |
public static void main(String args[]) | |
{ | |
Over Obj = new Over(); | |
Obj.add(55.6f,23.9f); | |
Obj.add(1996); | |
Obj.add(99,53); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment