我正在学习核心java并练习它。我理解方法重载的概念。但是当我运行下面的程序时,它显示错误为“
constructor Methodover in class Methodover cannot be applied to given types;
Methodover m2 = new Methodover();
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length"
请在下面找到我的代码并提供帮助。我只是在学习。
public class Methodover
{
int x;
int y;
Methodover(int a, int b)
{
x=a;
y=b;
System.out.println("The values assigned are" +x+ "And" +y);
}
void multiply(Methodover obj)
{ obj.x = 2;
obj.y = 2;
System.out.println("The multiplication result with object passed is" +obj.x*obj.y );
}
public static void main(String[] args)
{
Methodover m1 = new Methodover(5,6);
Methodover m2 = new Methodover();
m2.multiply(m1);
}
}