• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

clarification if condition

Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
this is my code

Can anyone let me know how to interpret second if condition.also what will be result here in second if.
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you get that time of execution?
Posts: 9671
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Boolean b1=true;
Boolean b2=false;
Boolean b3=true;


Here first of all this will be executed.
This is because expressions are evaluated from left to right
so b1 will become false. Since this will result in a boolean value so there will be no compile time error.
So the first value will be false

Then (b1&b3) will be evaluated. Since b1 is false so it will result in false.

Then (b1|b2) will be evalued. Since both b1 and b2 are false, so this will result in false.

So at last the whole condition will becode


which will result in false so beta will not be displayed.

Also your code has declarations Boolean and not boolean. Although this will work but I just want to remind you...
[ August 08, 2008: Message edited by: Ankit Garg ]
Oh. Hi guys! Look at this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic