Suppose you start with
// Set<String>
Object arrayOfSomething[] = someObject.toArray();
Now, i know that arrayOfSomething is really an arrayOfStrings, i’d like to iterate over
Currently, i
for (Object o : arrayOfSomething) {
String strValue = ((String) o).trim();
...
Is something along the following possible:
for (String (String) strValue : arrayOfSomething) {
...
Is it possible to cast an object as part of a fast enumeration?
There is also a method
Collection.toArray(T[])returning an array of type T instead of an array of Objects.