重载sub函数,使得其函数既能接收两个都为int类型的变量,也 ouble能接收两个都为类型的变量 主函数中包含下列代码

img

img


我的为什么不对

static只能访问static,成员方法需要new 对象访问

public class Test{
    int sub(int a,int b){
      return a-b;
    }
    double sub(double a,double b){
      return a-b;
    }
  public static void main(String [] args){
    Test test = new Test();
    System.out.println(sub(10,1));
    System.out.println(sub(10.0,1.0));

  }
}