Iterating through List

Hi All,

I am failly new to Java

I am getting List testqueue as a result of query.I am casting it to Task Object

Task object has property named status.

I want to check if all the elements in List has status 30

How can I check this.

Following is the code

List testqueue

for (Iterator it1 = testqueue.iterator(); it.hasNext(); ){

Task task = (Task) it1.next();

int status = task.getStatus();

// now how to check that all the elements in this list have status== 30 ?

}

I will appriciate your help.

Thanks.

[753 byte] By [garsuma] at [2007-10-2 15:07:05]
# 1

if (status == 30) {

// it does

} else {

// it doesn't

}

yawmarka at 2007-7-13 13:59:07 > top of Java-index,Java Essentials,New To Java...
# 2
P.S. [url= http://en.wikipedia.org/wiki/Magic_number_%28programming%29]Magic Numbers[/url] are a "Bad Thing"?
yawmarka at 2007-7-13 13:59:07 > top of Java-index,Java Essentials,New To Java...
# 3

final int value = 30;

boolean allHaveCertainValue = true;

for (Iterator it1 = testqueue.iterator(); it.hasNext(); ) {

Task task = (Task) it1.next();

int status = task.getStatus();

if(status != value) {

allHaveCertainValue = false;

break;

}

}

System.out.println("All tasks have value "+value+"? "+allHaveCertainValue);

prometheuzza at 2007-7-13 13:59:07 > top of Java-index,Java Essentials,New To Java...