bhavneet kaur wrote:
here i=0 ,because its post increment and i will increment after using system.out.println
when j=j+i ,now i should have increment to 1 but j=0 ???
No, i think you haven't read the articles properly.
1) When you have this
i will remain 0 only. No matter even if you have any statement after this. So you said
because its post increment and i will increment after using system.out.println is wrong.
variable i will be 0
Therefore,
j = j + i will result in 0 and not 1 since both "j" and "i" are 0.
Secondly, in the program which you posted now, there is no use of the static method f1, since you haven't used it.
Any more doubts, feel free to ask.