kobycool68

kobycool68

  • NA
  • 23
  • 0

ArrayList

May 25 2004 8:59 AM
hello i have two classes class1 { private ArrayList arr; public class1() { this.arr = new ArrayList(); arr.add("bye"); arr.add(.....); . . . . } void func1() { new class2(this.arr); } public ArrayList arr1 { set{this.arr=value} get{return this.arr} } } class2 { class1 c1; private ArrayList arrCopy; public class2(ArrayList arr) { this.arrCopy = arr; } ........ void func() { c1.arr1.insert(0 , "hello"); } my question is: suppose i change element 0 from "bye" to "hello" in class2 , why arrCopy is change element 0 too???? how can i avoid it?? thank you very much koby

Answers (1)