This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Please Explain  RSS feed

 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println("i j");
int i=2;
long j=2L;
for (i++, j=(long)0; j<3; System.out.println(""+i +" "+j++));

Please explain
 
High Plains Drifter
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Judging by the looks of it, it appears to be a fragment of Java code.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
Gold Digger
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's the deal ??
output is
3 0
3 1
3 2
which is perfectly normal
the initialization part is
i++, j=(long)0
i's value is now 3 and j's 0
the condition part is j<3 which means that the loop will iterate three times (j=0,j=1,j=2)
the update part is
System.out.println(""+i +" "+j++)
which prints i's and j's values, the value of i is always 3 and the value of j is increment from 0 to 2...
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Then YOU must do the pig's work! Read this tiny ad. READ IT!
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!