+ 3
How can i use non static variables in class methods??
when i use them, my code didn't run and message non-static variable cannot be referenced from a static context what can i do to solve this problem and don't use static variable??
3 ответов
+ 15
You have to firstly create an instance of that class, then only you can call non-static methods, like this:
MyClass itsInstance = new MyClass(); // Created instance of class
itsInstance.yourNonStaticMethod(); // Non Static method called
+ 6
About static/non static:
https://www.sololearn.com/discuss/1665058/?ref=app
0
Yo can use get() and set() methods,too