Hello ! The best way would by to try it out. I guess the answer is "2". Reason: "i" will only change its value with the evaluation of "method1(i++)". This term is not evaluated in //2 and //4 due to short circuit evaluation of && (||) and the value of bool2 (bool1). It is evaluated in //1 and //3, 0+1+1=2. The statements in the method do not harm, 'cause && and || are evaluated left to right. But as I said, try it out. It's the best way to understand what's going on. add a "System.out.println(i)" after each assignment to bool. Greetings from Euroland, Stefan
Author of German LDAP-Book
Committer at Apache Directory Project
good question sonir... i++, post increment ... so i sends its current values as the parameter to the method and then increments itself.. In the short circuit operations.. RHS never gets executed , so we save couple of computations resulting the value of i to be '2' Is it helpful? Ragu
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth