Change a variable in another class based on a variable string.

I hope the subject made sense, but essentially what I want to be able to do is have a string that I can change which refers to a variable in another class which I can then change.

Something like this.


String variable = "speed";

public void method(Object ob){
    ob.getVariable(variable) = 3;
}

This of course is not how it would look but I hope it helps in understanding what it does.