nested List<T> without implementing Clonable in Parent Classes ?
Hello. Afaik, you can't. More important, if you need deep copy, your T should also be Cloneable. There's a dedicated chapter/receipt in Joshua's Bloch "effective Java" to implementing Cloneable. Or you can implement it yourself via copy constructor. This is more tedious but you have full control over the process: how deep, what to deep clone, what to copy reference and so on
I mean, copy constructor is your choice if T is not Cloneable and you don't have access or can't change T source
Обсуждают сегодня