need help!!

hi i need some help with my java code.

String word1="junction";

String word2="segment";

String word3="busline";

String word4="busstop";

boolean w1,w2,w3,w4;

w1=false;

w2=false;

w3=false;

w4=false;

ArrayList list =new ArrayList();

String[] h = line.split(" ");

for (String tempString : h){

list.add(tempString);

}

for(Iterator iter = list.iterator(); iter.hasNext();){

String e=(String)iter.next();

if(e.equals(word1)){w1=true;}

elseif(e.equals(word2)){w2=true;}

elseif(e.equals(word3)){w3=true;}

elseif(e.equals(word4)){w4=true;}

}

this will give me something like:

truefalsefalsefalse

falsetruefalsefalse

falsefalsetruefalse

truefalsefalsefalse

how could i create a method that goes:

if(w1 ==true && w2 ==true && w3 ==true && w4 ==false){

do something...

}

because at the moment this would scan each line, but i want to scan the whole thing!!

[2402 byte] By [da_master_of_nuthina] at [2007-11-27 2:57:14]
# 1
http://www.catb.org/~esr/faqs/smart-questions.html#bespecific
prometheuzza at 2007-7-12 3:35:35 > top of Java-index,Java Essentials,New To Java...
# 2

for(Iterator iter = list.iterator(); iter.hasNext();)

{

String e=(String)iter.next();

if(e.equals(word1)) { w1=true; break; }

else if(e.equals(word2)) { w2=true; break; }

else if(e.equals(word3)) { w3=true; break; }

else if(e.equals(word4)) { w4=true; break; }

}

radicjesa at 2007-7-12 3:35:35 > top of Java-index,Java Essentials,New To Java...
# 3

The breaks don't do anything since they are all else ifs. Only one of the blocks will be entered even without the breaks. The OP sounds like he only wants to enter a single block if all four booleans are true, but he provided the code for that himself, so I'm not exactly sure what he's after. Possibly an array of booleans?

hunter9000a at 2007-7-12 3:35:35 > top of Java-index,Java Essentials,New To Java...
# 4

let me clear this up, basically i want to create a statement to say that if w1 is true, w2 is true, w3 is true and w4 is false then i will do something. At the moment it scans each line not the whole list.

so if i put if(w1 == true && w2 == true && w3 == true && w4 == false)

it will come up with line that agrees with this, but i want to search the whole list.

w1 w2 w3 w4

truefalsefalsefalse

falsetruefalsefalse

falsetruefalsefalse

falsetruefalsefalse

falsefalsetruefalse

falsefalsetruefalse

da_master_of_nuthina at 2007-7-12 3:35:35 > top of Java-index,Java Essentials,New To Java...
# 5
remove the else's will work for you if i understand it
radicjesa at 2007-7-12 3:35:35 > top of Java-index,Java Essentials,New To Java...