Core java- initialize object | Selenium Forum
M
Posted on 18/12/2015
public class Test {

Test t1= new Test();
int i;
static int j;
static Test t2 = new Test();
public static void main(String[] args) {
t1.i=10; //1
i=19; //2
j=10; //3
t2.i=19; //4

}
}

here i dont understand why error are displaying at line no 1 ,2 please explain me.

M
Replied on 18/12/2015

static main method cannot access non static variables.


M
Replied on 21/12/2015

Thanks Admin