+ 6
Can we access a non-static variable in the static context on java?
2 Respuestas
+ 1
why should be easy to understand. accessing non-static elements means accessing members of an object of the class to which the static element belongs. but since the static element is shared among all the objects of that class and exists in the moment in which a class is defined without the need for an object to be instantiated, how can a static method choose and access non-static elements, therefore the members of a object that may not exist, be one or n?
0
You have to make the objects of them to acess in main