method overloading
//https://www.geeksforgeeks.org/overloading-in-java/
// Java program to demonstrate working of method
// overloading in Java.
public class Sum {
// Overloaded sum(). This sum takes two int parameters
public int sum(int x, int y)
{
return (x + y);
}
// Overloaded sum(). This sum takes three int parameters
public int sum(int x, int y, int z)
{
return (x + y + z);
}
// Overloaded sum(). This sum takes two double parameters
public double sum(double x, double y)
{
return (x + y);
}
// Driver code
public static void main(String args[])
{
Sum s = new Sum();
System.out.println(s.sum(10, 20));
System.out.println(s.sum(10, 20, 30));
System.out.println(s.sum(10.5, 20.5));
}
}
Also in Java:
- main method java
- basic java coding
- map with insertion order preserved java
- how to create a button in java
- How to find the length of an array in java
- math max java
- java variables in annotations
- java android edit text set value
- how to separate no and text in java
- creating a program about user asked to enter a number and enters 0 to stop, then calculates the sum of numbers entered, the average, the length of positive numbers and negative numbers entered by the user in java
- java add element to existing array
- spring framework iterate
- java string to integer
- android elevation not working
- primitive data types in java
- jackson ignore value if null
- java do while
- get raondom from array java
- graal.js pass javascript array to java function
- how to append to a string in java
- java map get the key from value
- java file path linux
- java concatenate arrays
- append to arraylist by index java