In the statement, i=i++ + f(i), i++ is evaluated first. At this point i=0. The i passed to the function f() has the value 1.
1 is printed in the function. 0 is returned. now the expression i= i++ + f(i) becomes i=0+0 thus the value of i is changed to 0. On Sat, Aug 6, 2011 at 8:29 PM, swetha rahul <swetharahu...@gmail.com>wrote: > Hi, > class C{ > static int f1(int i) { > System.out.print(i + ","); > return 0; > } > public static void main (String[] args) { > int i = 0; > i = i++ + f1(i); > System.out.print(i); > }} > > > Why does this print 1,0..?? Please explain... > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.