compound if statement

Can someone why this isn't working. Only the 1st equation is evaluated.

String attributeToChange.=" "

if(!attributeToChange.equals("a") |

!attributeToChange.equals("b") |

!attributeToChange.equals("c)){

attributeToChange= "this var is NOT equal to a , b or c";

}else{

attributeToChange= "this var IS equal to a , b or c";

}

[381 byte] By [anonymousJoea] at [2007-11-26 22:29:07]
# 1
Think about or.
DrLaszloJamfa at 2007-7-10 11:32:51 > top of Java-index,Java Essentials,Java Programming...
# 2
I still lost. what about or !
anonymousJoea at 2007-7-10 11:32:51 > top of Java-index,Java Essentials,Java Programming...
# 3
Okay, think about or !
DrLaszloJamfa at 2007-7-10 11:32:51 > top of Java-index,Java Essentials,Java Programming...
# 4
Think about what happens if attributeToChange is "foo".
DrClapa at 2007-7-10 11:32:51 > top of Java-index,Java Essentials,Java Programming...
# 5
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/opsummary.html
CaptainMorgan08a at 2007-7-10 11:32:51 > top of Java-index,Java Essentials,Java Programming...
# 6

For example:String myCar = "chevy";

if (myCar.equals("honda") || myCar.equals("toyota"))// if (false or false) evaluates to false

{

System.out.println("1. This shouldn't print");

}

if (myCar.equals("honda") || myCar.equals("chevy"))// if (false or true) evaluates to true

{

System.out.println("2. This will print");

}

if (!myCar.equals("honda") || !myCar.equals("toyota")) // if (true or true) evaluates to true

{

System.out.println("3. This will print");

}

if (!myCar.equals("honda") || !myCar.equals("chevy")) // if (true or false) evaluates to true

{

System.out.println("4. This will print");

}

KelVarnsona at 2007-7-10 11:32:51 > top of Java-index,Java Essentials,Java Programming...
# 7
Ok , it finally sunk in thanks all especially KelVarnson and DrLaszloJamf . I would have got this at about 1:00 am ESTThanks again
anonymousJoea at 2007-7-10 11:32:51 > top of Java-index,Java Essentials,Java Programming...
# 8

this works

String attributeToChange.=" "

if(!attributeToChange.equals("a") &&

(!attributeToChange.equals("b") )&&

(!attributeToChange.equals("c))) {

attributeToChange= "this var is NOT equal to a , b or c";

}else{

attributeToChange= "this var IS equal to a , b or c";

}

anonymousJoea at 2007-7-10 11:32:51 > top of Java-index,Java Essentials,Java Programming...