I
iksrazal
Hi all, this is not a homework assignment, I'm just trying to figure
out the best way to do this.
I have two lists of the same size, filled with Long :
useValues(List listA, List listB);
I want to iterate over each so I can do something with the values:
for (Iterator iterA = listA.iterator(); iterA.hasNext() {
Long valA = (Long) iterA.next();
}
And
for (Iterator iterB = listB.iterator(); iterB.hasNext() {
Long valB = (Long) iterB.next();
}
I want to use valA and valB like so:
doSomething(valA, valB);
My idea is this:
Long[] longArrayA = (Long[]) listA.toArray();
Long[] longArrayB = (Long[]) listB.toArray();
if (longArrayA.length != longArrayB.length) {
throw new IllegalArgumentException();
}
for (int xx = 0; xx < longArrayA.length; xx++) {
Long valA = longArrayA[xx];
Long valB = longArrayB[xx];
doSomething(valA, valB);
}
Any ideas? I'm using java 1.4.2 .
iksrazal
out the best way to do this.
I have two lists of the same size, filled with Long :
useValues(List listA, List listB);
I want to iterate over each so I can do something with the values:
for (Iterator iterA = listA.iterator(); iterA.hasNext() {
Long valA = (Long) iterA.next();
}
And
for (Iterator iterB = listB.iterator(); iterB.hasNext() {
Long valB = (Long) iterB.next();
}
I want to use valA and valB like so:
doSomething(valA, valB);
My idea is this:
Long[] longArrayA = (Long[]) listA.toArray();
Long[] longArrayB = (Long[]) listB.toArray();
if (longArrayA.length != longArrayB.length) {
throw new IllegalArgumentException();
}
for (int xx = 0; xx < longArrayA.length; xx++) {
Long valA = longArrayA[xx];
Long valB = longArrayB[xx];
doSomething(valA, valB);
}
Any ideas? I'm using java 1.4.2 .
iksrazal