[英]Eclipse error during compilation of a parameterized contructor code
When I write a simple parametrised constructor program, it compiles and runs in the command line. 当我编写一个简单的参数化构造函数程序时,它将在命令行中编译并运行。
However when it is executed within the Eclipse IDE, I received the following exception: 但是,当它在Eclipse IDE中执行时,我收到以下异常:
Exception in thread "main" java.lang.NoSuchMethodError: a_constructor.Test.(II)V at a_constructor.ParametrizedConstructor.main(ParametrizedConstructor.java:15).
线程“主”中的异常java.lang.NoSuchMethodError:a_constructor.ParametrizedConstructor.main(ParametrizedConstructor.java:15)上的a_constructor.Test。(II)V。
Code : 代码:
//write a java program which listed the concept of parameterized constructor
class Test {
int a,b;
Test (int x, int y) {
a=x;
b=y;
System.out.println("========================");
System.out.println("value of a=" +a);
System.out.println("value of b=" +b);
System.out.println("========================");
}
}
public class ParametrizedConstructor {
public static void main(String[] args) {
Test t1=new Test(10,20);
Test t2=new Test(100,200);
Test t3=new Test(1000,2000);
}
}
The ParametrizedConstructor
code is clean and doesn't have any issues. ParametrizedConstructor
代码很干净,没有任何问题。
Try: 尝试:
Alternate Solutions: 替代解决方案:
ParametrizedConstructor.java
(ie., public class) ParametrizedConstructor.java
(即,公共类)匹配。 For References - Check also the below links for better understanding: 供参考-还要检查以下链接以更好地理解:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.