What is overloading

A class that contains two or more methods with the same name but different parameter lists is called method overloading.

Application of overload

Both are maximums, but one takes a floating point argument and the other an integer.

* */ package Demo1; publicclass chongzai {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Abc abc=new Abc();
		System.out.println("The larger number is:"+ abc.GetMax(12.14));
		System.out.println("The larger number is:"+ abc.GetMax(12.5f, 12.4f)); }}class Abc
{
	// Return a larger integer
	public int GetMax(int i,int j)
	{
		if(i >= j) 
			return i;
		else 
			return j;
	}
	// Returns a larger floating point number
	public float GetMax(float i,float j)
	{
		if(i >= j) 
			return i;
		else 
			returnj; }}Copy the code

The results