This week's giveaway is in the Groovy forum.
We're giving away four copies of Groovy Fundamentals video training course and have Ken Kousen on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to make my class iterable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

How to make my class iterable?

Theodore David Williams
Ranch Hand

Joined: Dec 21, 2009
Posts: 102
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4530
    
    8

You need to implement the Iterable<T> interface.

Edit...incidentally, you can get that by looking at the language specification:
14.14.2 The enhanced for statement
The enhanced for statement has the form:
for ( VariableModifiersopt Type Identifier: Expression) Statement
The Expression must either have type Iterable or else it must be of an array type, or a compile-time error occurs.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 42581
    
  31
Please read this. Closing thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make my class iterable?