Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes for loop problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "for loop problem" Watch "for loop problem" New topic

for loop problem

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924

please refer the kb6 book page no 349. the book says

The next example demonstrates a for loop with multiple variables in play. A
comma separates the variables, and they must be of the same type. Remember that
the variables declared in the for statement are all local to the for loop, and can't
be used outside the scope of the loop

why is this happening ?
John Jai

Joined: May 31, 2011
Posts: 1776
I don't have the book for reference. May be the book refers to declaring more than one type in the for loop.

Helen Ma
Ranch Hand

Joined: Nov 01, 2011
Posts: 451
In a for loop , only one type of variable can be declared, according to the KB book.
I agree. Here's the link:
subject: for loop problem
jQuery in Action, 3rd edition