I have a simple question: is there a better way to create a collection that holds any-type objects. I have it like this:
Queue<Object> queue = new LinkedList<Object>();
queue.add("First Element");
queue.add(2);
queue.add(true);
As I was reading about gerenic wildcards, I thought I could do something like this:
Queue<?> queue = new LinkedList<?>();
But I realise, that it is wrong, so I ask if my procedure is correct and how could I improve it using wildcards if possible.
Thanks for input everyone. Elaborating: I want to use this queue collection to store an unknown number of unknown objects, then perform an action with each of them in a loop. Hence, here I have a dilemma: what would be the best practice to create such a collection.