Programmers learn & share
0 votes
410 views

Problem :

I am getting bellow error 
can only iterate over an array or an instance of java.lang.iterable

by (6.9k points)   | 410 views

1 Answer

0 votes

Solution :

Probably you have not selected the correct method for your for loop. 

You need to break the tiles string down into characters by using toCharArray() instead. 

The indexOf() method will return the position of the char is within the string. And we want to iterate over the string so we need an iterable object that is what your error is saying.

Using toCharArray() converts a string to an iterable array that your for loop can pass over one char at a time.

Further Readings:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=400624

by (36.1k points)  
edited by
2,187 questions
2,514 answers
59 comments
241 users