Lets say I have the following code in front of me:
public class Theory {
public static void main(String[] args) {
new Theory().program();
}
void program(){
A.a = A.b; //won't compile
A.a = new A().b;
A.b = A.a; // won't compile either
new A().b = A.a
}
static class A{
static int a;
int b;
}
}
When I hover the mouse over the code it says "non static field cannot be referenced from a static context", which I sort of understand, but I can't wrap my head around why the consecutive line doesn't show a compiler error?