Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

A bug on the vector????

843836Feb 22 2005 — edited Feb 22 2005
I have this strange problem.. my program first creates an vector of names and number. and when data is added, the vector are added into another vector (a main vector ). It works well when i use vector.add. Strangely, the older name and number vectors does not expire and its older data, along with the newer data , are appended into the main vector. I did a vector.clear() to clear off the older name and number before impending the new names and number.

Problem is , it seems strange that when i clear the name and number vector, it clears the name and numbers in the main vector as well.. anyone have any idea why?

<--- Setting the name and number-->
for(int icu=0;icu<contactUpdate.length;icu++){
String[] retrieved=contactUpdate[icu].split("@");
SB.setName(retrieved[0]);
SB.setNumbers(retrieved[1]);
<--- setting name andnumber -->
public void setName(String nm){
name.add(nm);
}
public void setNumbers(String number){
numbers.add(number);
}
<--- update past records -->
SB.updateRecord(((chk+1)*2)-1);
public void updateRecord(int i){
record.set(i-1,name.clone());
record.set(i,numbers.clone());
}

<--Assume that there is already data in those index and I'm replacing it with a new data in that index in main vector -->

<!-- clear the name and number -->
public void flushNameNNumber(){
name.clear();
numbers.clear();
}
To prevent it from clearing the record.. I tried using a clone so that it makes a copy and does not have any link with the actual name and number.. but... still gets affected...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 22 2005
Added on Feb 22 2005
3 comments
129 views