• Post Reply Bookmark Topic Watch Topic
  • New Topic

Collections reverse  RSS feed

 
Wisogota Zpankok
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Can only iterate over an array or an instance of java.lang.Iterable

How can I change this code to the method reverse(list) to work properly.



 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change the return type from Iterator into Iterable, and return the List itself. Of course you need to change the loop variable - the List does not contain Lists.
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Return the list itself, since it implements Iterable:


 
Wisogota Zpankok
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Paul Clapham, for your prompt reply.
Already changed and it works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!