// Create an array containing the elements in a list Object[] objectArray = list.toArray(); MyClass[] array = (MyClass[])list.toArray(new MyClass[list.size()]); // Create an array containing the elements in a set objectArray = set.toArray(); array = (MyClass[])set.toArray(new MyClass[set.size()]); // Create an array containing the keys in a map objectArray = map.keySet().toArray(); array = (MyClass[])map.keySet().toArray(new MyClass[set.size()]); // Create an array containing the values in a map objectArray = map.values().toArray(); array = (MyClass[])map.values().toArray(new MyClass[set.size()]);
I wanted a place where I can post technical articles only. This is the place to find out my tips and tricks for being a Java web applications developer. I hope it helps you.
Friday, March 25, 2011
One of My Faves
Converting a Collection to an Array
Subscribe to:
Posts (Atom)