I would like to make a clone of my arraylist by this code:
ArrayList<String> _names;
ArrayList<String> names = (ArrayList<String>) _names.clone();
As far as I know, nothing special. My compiler however, gives the following warning:
Type safety: Unchecked cast from Object to ArrayList<String>
Does anybody know a cleaner solution that does not give me a warning?
ArrayList<?>will not give this warning. Do you need it to be anArrayList<String>? Can you calltoStringon the resulting elements instead?