Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

K&B chap 4, Self test question help

 
Siri Naray
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class titanic {
public static void main(String[] args)
{
Boolean b1 = true;
boolean b2 = false;
boolean b3 = true;
if((b1&b2) |(b2&b3) &b3)
System.out.println("alpha");
if((b1=false)|(b1&b3)|(b1|b2))
System.out.println("beta");
}

}

No output is produced for this. but since the 2nd "if" results to "true" ((b1&b3)is true also (b1|b2) is true) the output shud be "beta".

Can anyone explain why there is no output for this program???
Thank you in advance
Sirisha
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look carefully at the second "if" statement, and ask yourself what this...

(b1 = false)

...is doing.
 
Siri Naray
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wooooooooow how i missed that!1 thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic