6
Because the method is static and the variable being used is instance. There is no relationship between them. Static members have as "owner" the class. There is only one throughout the application. Instance members have as "owner" the current instance, that is, each object created from that class owns its members. You can have as many as you want. Since the owners are different, one member cannot access another owner’s member.
The solution is to take the static
method. It may be that the solution is to place a static
variable. I have no way of knowing what you have in the question.
Read this: http://meta.pt.stackoverflow.com/q/5149/101
– Maniero
Since
service
is not static, you can not call theservice
by a static method.– Falion
Oops, corrected here haha. I’m laughing, is that I wrote but with the intention of testing to see if it worked even.
– Aline