Hi,
public class
Test {
static int a;
int y=10;
public static void main(
String[] args)
{
System.out.println(" y = " + y);
}
}
I tried to complie the above code, it's shows up error that non-static variable can't be referenced in the static method. Okay.
Then I tried the following code:
public class Test
{
static int a;
public static void main(String[] args)
{
int y=10;
System.out.println(" y = " + y);
}
}
Now I complied the above code, I got the result as y = 10. the int y has no static keyword, then how it is accepted by the static method