Menu
Ok I just started learning Java. I’m using this tutorial: [url]http://java.about.com/od/beginningjava/a/beginjavatutor.htm
[code]
public class HelloWorld {
private int somevar = 5;
public static void main(String[] args) {
System.out.print(somevar);
}
}
but I get this error:
[code]
Exception in thread “main” java.lang.Error: Unresolved compilation problem:
Cannot make a static reference to the non-static field somevar
it works if I delcare somevar like this: “private static int somevar = 5;”. But I don’t want it to be static. Help please ?