Skip to content

Instantly share code, notes, and snippets.

@raikusy
Last active June 13, 2017 20:15
Show Gist options
  • Save raikusy/996c6b304f1f082042356b6ed41f9d44 to your computer and use it in GitHub Desktop.
Save raikusy/996c6b304f1f082042356b6ed41f9d44 to your computer and use it in GitHub Desktop.
Method Overloading in Java
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