Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

How to make my class iterable?

 
Theodore David Williams
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Report post to moderator
 
Matthew Brown
Bartender
Posts: 4566
8
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please read this. Closing thread.
 
    Bookmark Topic Watch Topic
  • New Topic