Declaring unknown ArrayList
Posted on 2003-11-28
I'm stuck with the following:
In normal circumstances, declaring an ArrayList in java will be:
ArrayList mylist = new ArrayList();
But I want to declare something like that:
String x = "apple";
The ArrayList will have to be named as the value of String x, ie "apple".
The value of x will only be known during runtime, thus unable to declare it
as : ArrayList apple = new ArrayList();
Anyone has solution to this problem, please kindly post here.
Thanks a lot.