Originally posted by carlos olmos:
And wich one is the correct way ?
Well, which one is correct really depends on what you have in your collection. The first method you showed (using a cast) works great if what's in the collection really is a String. However, if you had something else in there, like an Integer, you'd get a ClassCastException at runtime. In that case, you'd want to use the toString method of Integer (or whatever other object you have in there) in order to get a textual representation of that object.
I hope that helps,
Corey