j'ai essayé ta méthode de cette façon:
Code :
- obj2.methode((MonObjet1[])tabObjet1.clone());
|
mais cela fait exactement la même chose, tabObjet1[] est toujours modifié après l'appel.
J'ai cherché de l'aide sur clone() j'ai trouvé ça dans la doc:
Note that all arrays are considered to implement the interface Cloneable. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation.
d'après ce que je comprends clone() ne permet pas de cloner les objets attributs de MonObjet1 s'ils sont complexes (c'est mon cas).
Dans ce cas comment faire ?