File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Infinite for loop....???

 
Naveen Raja
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can you please tell me how the following for loop can be a infinite loop..

for(int i=0;i<=012;i=i++)
{
}

I think the whole point is increment operation on i.When exactly it happens...??

Thanks a lot
Cheers,

Naveen

 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The whole point is that i=i++ is equivalent to i=i.
i gets evaluated before being incremented.

Try this :
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read this one from the FAQ: Post increment operator and assignment

By the way, can you guess what this code will print?

I bet you will be surprised with the output.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic