方法'main'必须在'Rextester'类中。
import java.util.*;
import java.lang.*;
class Sathya{
String a,b;
Sathya (String x,String y)
{
a=x;
b=y;
}
Sathya ( Sathya x1,Sathya x2)
{
a=x1.a+" "+x2.a;
b=x1.b+" "+x2.b;
}
void disp()
{
System.out.print(a+" "+b);
}
} Opcd {
public static void main(String args [])
{
Sathya s1 =new Sathya("java", "india");
s1.disp();
}
}
****错误方法'main'必须在'Rextester'类中。****
答案 0 :(得分:0)
在Eclipse中,编译器说:The method main cannot be declared static; static methods can only be declared in a static or top level type
。你有它。
您只能在顶级类中声明main方法,即Sathya类,而不能在内部类中声明。