I wrote a class Ex1 that has a public double variable. It's global, therefore it's defined outside of any method. Now, can I get access to this variable in another class, called Ex2? If so, what is the syntax to do this?
Printable View
I wrote a class Ex1 that has a public double variable. It's global, therefore it's defined outside of any method. Now, can I get access to this variable in another class, called Ex2? If so, what is the syntax to do this?
If doubleMember is an instance variable.Code:Ex1 x1 = new Ex1();
x1.doubleMember = 2d;
What does that mean? I'm not familiar with the global keyword.Quote:
It's global
Quite.
There isn't really such a thing in Java.
The closest is a "public static" attribute.
when he says global, he refers to a class variable..
Except they don't say it's a class variable, because they don't say it's static. They merely say "it's defined outside of any method", and it's public. Which to me implies it's a member attribute, not a static class attribute.