This is illegal becuse you are reffering a non static method from a static code. Non static members have to be assosiated with a object.
So this works but if i was declared outside main and I tried to use it this would not.Also if i declare a variable or method inside static method .Does it automatically become static ??
Dont be confused between static and local variables. Read a basic book on
Java like Head First