Is it possible to make a class getter/setter that can take any of the class attributes as an argument so as not to have to make a getter/setter pair for each attribute needed?
I am new to Java
For example, is something like this possible?
class Someclass {
int var1;
int var2;
int var3;
public int getanyvar(Attribute varname) {
return varname;
}
public void setanyvar(Attribute varname, int value) {
varname = value;
}
}
I don't really recommend this, but you could easily do it with a switch
Just make getters and setters for each attribute, I feel like this way of doing things would get annoying and confusing.