i have two vectors a and b.
i need to write elements from vector b that are at the same index as equal elements in vector a.
if in vector a elements a(0) and a(5) are equal i write b(0) and b(5) into another vector.
for (int i=0, n=a.size(); i<n; i++){
onenode = (String)a.get(i);
if (!visited.contains((String)a.get(i))){
for (int j=0, m=a.size(); j<m; j++){
secondnode = (String) a.get(j);
if (secondnode.equals(onenode)){
selectednets.add((String)b.get(j));
}
}
visited.add(onenode);
}
// selectednets.removeAllElements();
}
if i uncoment vector clear i get empty vector and if i leave it all elements of b are stored in the selectednets vector.
can anybody explane what am i doing wrong?
i need to write elements from vector b that are at the same index as equal elements in vector a.
if in vector a elements a(0) and a(5) are equal i write b(0) and b(5) into another vector.
for (int i=0, n=a.size(); i<n; i++){
onenode = (String)a.get(i);
if (!visited.contains((String)a.get(i))){
for (int j=0, m=a.size(); j<m; j++){
secondnode = (String) a.get(j);
if (secondnode.equals(onenode)){
selectednets.add((String)b.get(j));
}
}
visited.add(onenode);
}
// selectednets.removeAllElements();
}
if i uncoment vector clear i get empty vector and if i leave it all elements of b are stored in the selectednets vector.
can anybody explane what am i doing wrong?