+ 1

class

How to access a property in a class from another class???

1st Sep 2017, 10:27 PM
Reza Sharifi
Reza Sharifi - avatar
2 ответов
+ 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();
1st Sep 2017, 10:46 PM
Tashi N
Tashi N - avatar
+ 1
Thanx.
20th Apr 2018, 7:52 AM
Reza Sharifi
Reza Sharifi - avatar