packageJava Basics 06_ Object-oriented;/* * overloading of methods: * Requirements: We need the sum of numbers * Our requirements are constantly changing, so we provide multiple summation methods * but they all have the same name, and we can demand that we know by name. * agree before but we didn't do get * in reaction to the phenomenon, Java has solved the problem for us * proposed a solution: method of overloading method overloading: * * * in the same class, the same method name, argument list, or parameter types are different, or different number of parameters, has nothing to do with the return value. * /

/* * Access modifiers return type method name (argument list){* (method statement body) code block; *} * /
public class FuncationDemo {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub		

      FuncationDemo f=new FuncationDemo();
     int i= f.sum(2.3);
      System.out.println(i);// Output: 5
      String j=f.sum("44".3.6);
      System.out.println(j);// Output: 449
      int k=f.sum(2.3.4.5);
      System.out.println(k);// Output: 14
	}
	
	static int sum(int a,int b) {
		return a+b;
	}
	static String sum(String a,int b,int c) {
		return a+(b+c)+",";
	}
	static int sum(int a,int b,int c,int d) {
		returna+b+c+d; }}Copy the code