• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
49 views

Problem :

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

by (6.9k points)  

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 (20.3k points)  
edited by
...