Java common errors < identifier > expected

Case 1:

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

Example 2:

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

Compiling the former results in the following error:

The reason is that the statement written to call a method is not in the right place in the class and must be placed in a method.

Read More: