0

Dear all,

Scope resoultion operator is used to call the properties or methods of the class.

Properties :
===========
Variables
Constants

Why scope resoultion operator cannot be used for non-static variables .


Can any one help me out .

Thank you,

With Regards,
Prem

Edited by prem2: n/a

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Akill10
0

from what I just read online, there is no scope resolution operator in java. google it, and you'll find your answer.

0

As bibiki pointed out, there is no scope resolution operator in java. If you are not in the wrong section, and you are actually talking about java, Then the reason you cannot call not-static methods/variables using

Object.variable1 ..etc

Is because non-static variables/methods are Instance variables/methods. Meaning, they can only be accessed when an Instance(Object) is created.
i.e.

Object obj = new Object();
obj.variable1;

static variables, are Class variables, meaning, you do not need to create an Instance of the class to access them. You just explicitly use the name of the class and a .
i.e.

ClassName.variable2;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.