Java unsafe or unchecked expressions: cloning an arraylist
-
29-10-2019 - |
문제
I got the unchecked expression error when compiling and found the offending line to be
ArrayList<Integer> items = (ArrayList<Integer>) this.items.clone();
I am trying to perform a deep copy of my object so I am cloning a property of the object and array list in the above manner. How can I fix this warning?
- I could use
@SuppressWarnings("unchecked")
but that is just hiding the problem (tho I expect none) - If I clone manually by looping through all elements to it will be slower I think
Whats the correct way of doing this?
올바른 솔루션이 없습니다
제휴하지 않습니다 StackOverflow