How to create an independent copy of the object route
? The problem is that all the updates applied to route_copy
are also applied to route
. How to avoid this?
public class Route implements Cloneable, Comparable<Route> {
//...
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
//...
}
public void processData(Route route)
{
route_copy = null;
try {
route_copy = (Route) route.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
//...
}