Let's say I have this array:
String[] names = {"stack1", "stack2", "stack3"};
Is it possible to instantiate Stack
dynamically using those names, so there will be 3 objects named stack1
, stack2
, and stack
"? Later in the code, I'd like to call stack1.pop()
, or stack3.empty()
, for example.
I've been told to take a look at reflection, and still not sure how.