This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi Karthik , well it prints 0 because it never enter the for loop. this is your for statement: for (int i = 0, j = 10; total > 30; ++i, --j)
it states that i and j should start from 0, after every iteration i should increment with 1 and j should decrement with 1 but most importantly it specifies that loop should continue to run while value of total is greater then 0 now. before this statement you have written: int total = 0;
as the condition is already false. it never enters the for loop.
Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?