我尝试遵循所有语法规则,但无法运行我的代码。错误找不到符号...
Main class
public class Main {
public static void main(String[] args) {
Test my = new Test();
my.disp();
}
}
Test Class
class Test {
int a ;
int b;
Test()
{
System.out.println("Default constructor" );
a=102;
b=183;
}
void display()
{
System.out.println("Value of A" + a);
System.out.println("Value of B" + b);
}
}
最佳答案
您正在调用 my.disp()
,但类中有一个 display()
函数,而不是 disp()
关于java - 我正在尝试创建默认构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60125256/