Hi All:
Im have a question on referencing a class within a static method.
I have the below code:
public class Main
{
A atest;
public static void main(
String[] argv)
{
atest = new A();
}
}
class A
{
int i;
}
This code does not comile, it gives the error:
non-static variable cl cannot be referenced from a static context.
however i move
A atest;
inside main(),like:
public static void main(String[] argv)
{
A atest;
atest = new A();
}
i get no comilation error.
Could somebody tell me why.
Appreciate the help.
thanks,
Preetham.