Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

for loop  RSS feed

 
Vlada Den
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Is it possible to declare more than one variable in the initialization part of for loop?

If yes, could you post some code examples?

Thanks!

Vlada
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup.
 
Chris Wox
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for (byte i = 1, j = 1; i < 10 , i++, j++);
{ System.out.println(i + ":" + j) ;
}

you can also increment both variables
[ May 26, 2006: Message edited by: Chris Wox ]
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for loop
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that variables declared in a for loop must all be of the same type (i.e., as a single line of code).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!