aspose file tools*
The moose likes Beginning Java and the fly likes for loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "for loop" Watch "for loop" New topic
Author

for loop

Vlada Den
Ranch Hand

Joined: Dec 19, 2004
Posts: 32
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

Joined: Apr 14, 2004
Posts: 10336

Yup.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Chris Wox
Ranch Hand

Joined: May 25, 2006
Posts: 34
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

Joined: Feb 02, 2006
Posts: 2023
for loop
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Note that variables declared in a for loop must all be of the same type (i.e., as a single line of code).


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: for loop
 
Similar Threads
while loop
for and while loops
WA #2 ..... word association
WA #1.....word association
Codes For Practice