JAVA常见错误之<identifier> expected

例1:

public class line1{
int test1=666;
line2 l2=new line2();
l2.ShowIt(test1);
}

例2:

public class line1{
int test1=666;
line2 l2=new line2();
line1(){
l2.ShowIt(test1);
}}


编译前者会出现如下错误:


原因所写的调用方法的语句放在类中的位置不对,必须放在方法中进行。

猜你喜欢

转载自blog.csdn.net/qq_38329988/article/details/80854924