Boolean methods

I have a for loop that will go through objects in two ArrayLists. How can I do to break out of that loop if two elements from the two AL are not equal? And what will the boolean method surrounding it return?/mike
[226 byte] By [emkinsa] at [2007-10-2 10:06:47]
# 1

Do you mean something like this:boolean same(ArrayList alA, ArrayList alB) {

boolean areSame = true;

for(int ndx = 0; ndx < alA.size(); ndx++) {

Object a = alA.get(ndx);

Object b = alB.get(ndx);

if(!a.equals(b)) {

areSame = false;

break;

}

}

return areSame;

}

But notice AbstractList has an equals() method.

http://java.sun.com/j2se/1.5.0/docs/api/java/util/AbstractList.html

pbrockway2a at 2007-7-13 1:23:47 > top of Java-index,Java Essentials,New To Java...