+ 1
class
How to access a property in a class from another class???
2 Réponses
+ 9
Create a getter method in the class which owns the property.
Example:
You have a class Test with an int property called foo.
The getter method in the Test class would be:
public int getFoo(){
return this.foo;
}
You would call it from another class like this:
Test test = new Test();
int myInt = test.getFoo();
+ 1
Thanx.