As my title states I am trying to dynamically reference an instance of an object by a string. Since I likely do not use the exact correct technical terms, here is basically the starting situtation.:
MyClass instance123 = new MyClass();
String referer = "instance123";
What i want to do it, refer to the object instance123 by the String referer.
E.g.:
callObjectByString(referer).anyMethodOfMyClass();
Which i would normally call like:
instance123.anyMethodOfMyClass();
I hope this is somewhat understandable and possible. I know that there is always a different way to program amd I could surely work around this problem somehow but I still want to find a solution to this problem!