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?
names = new ArrayList<String>(_names);
Or use @SuppressWarnings("unchecked")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With