I hava a method setData(ArrayList<super> list), so anyone who want set data can have their own entity, just need to extends from super class. but when they call setData, how they convert ArrayList to ArrayList?
Now i use setData(new ArrayList(list)), but it’s not a good solution.
Anyone can tell me how to convert or another solution can avoid the problem. Very appreciated!
It depends on what you want to do with the list afterwards. If you’re just going to read from it, you can declare your method like this:
You can’t add anything to that list, though, because you won’t know what
?is. Another option is to create a copy when calling your method: