org.apache.cxf.jaxrs.ext.multipart.Attachment attachments=null;
List<Attachment> clone = new ArrayList<Attachment>(attachments.size());
for(Object item: attachments)
clone.add((Attachment)item.clone());//The method clone() from the type Object is not visible
I want to clone the List<Attachment> clone object but it saying The method clone() from the type Object is not visible
Do not use Java standard clone method from Object. At least not before you read what Josh Bloch says about cloning in his book Effective Java.
You need to do a deep copy in this case i.e create an empty ArrayList of Attachment objects (which you did) and copy the values of all the fields of every Attachment object.
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