geeta vemula wrote:oh i was so stupid...
First all the instantiation done where x will become 0 in tht line which is same since it is class variable. so printing 000000.
Thanks,
for clearing my doubt..
Thanks for explaination guys.
That line tricked me too.
I also thought the answer should be '000' becuase the print statement is executed three times.
But I manually went through the code step by step and figured out that the static
String variable 's' keeps the previous '0's and thus prints out 6-'0's.
Very tricky!
-Thank You