• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compound Assignment Operators  RSS feed

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


From about code value of i gets incremented at Line 5, but not at Line 3.

i+=2;
is nothing but
i=i+2;

So what is the difference between Line 3 and 6?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At line 3 you're printing false && true. Note that false && ANYTHING is always false.

 
Minal Silimkar-Urankar
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeff for your reply. I got my mistake.
 
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, with &&, if the left hand side is false, the right hand side is skipped. If you would have used & instead of && then i would have been incremented.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!