Lets say I have a class
class A {
string name;
int age;
string gender;
//assuming all the constructors, getters and setters are present
}
for purpose of simplicity, lets assume all these members are public and to access them I create an object of that class as follows
A a = new A();
is there a way to access the each member as follows
String string = "age"
a.string
and get the age of the object and so on. similarly, lets say I have a getter and can I access it using
String string = "getAge()";
a.string;
I am an beginner java programmer trying to optimize a code written in swift (needless to say I am a novice in swift), which has a class with more than 50 members and setting/getting each of them in some other module gets very tedious.
Just wondering if this is possible in either of the programming languages. In java I assume something like this might be possible using class reflection, but not very sure.