Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Bertha Ferguson   on Oct 26 In Java Category.

  
Question Answered By: Mae Roberts   on Oct 26

The error  is thrown when you have a static  method and in the body of that method
you try to access a non-static class
variable:

public static void main(String[] args){
myVar = new MyVar();
}

private myVar;


This should cause the same error. It is fixed by changing the last line to:

private static myVar;

Share: 

 
 
Didn't find what you were looking for? Find more on Non-static variables problem Or get search suggestion and latest updates.


Tagged: