• Register
0 votes
1k views

Problem :

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

6 5 3
6,930 points

Please log in or register to answer this question.

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

9 7 4
38,600 points

Related questions

0 votes
1 answer 26 views
26 views
Help me by solving this poblem.
asked Dec 17, 2020 TeamScript 10.1k points
1 vote
1 answer 366 views
366 views
Problem : I am very new to programming. I need to write a program called swapAdj that must accept the array of integers and after that swap those elements at the adjacent indexes. For example consider the elements 0 and 1 are swapped by the program and after ... note if your array has the odd length then the program must keep final element unmodified. Please help me in writing above program.
asked Apr 7, 2020 morrisBson 3.2k points
0 votes
1 answer 35 views
35 views
I want to know how to sort an array in java without using sort method.
asked Sep 28, 2020 Daniel Anderson 4k points
3 votes
2 answers 4K views
4K views
Problem: I am struggling with a problem for a few hours back. I know how to sort an array by using methods. I was looking for another way (perhaps a loop) to do it more efficiently. Let me put my question this way, how to sort an array in java without using sort method? Could anybody here please help to make this happen? Thanks in advance
asked Mar 24, 2020 Gavin 15.3k points
0 votes
1 answer 43 views
43 views
Problem: Hello kodlogs, How can we use for loop in the python to iterate over the sequence of element I have a confusion over the range() function and the datatype like list, tuple and string. Like how can we access the elements in the list
asked Jun 9, 2020 Gavin 15.3k points
0 votes
1 answer 16 views
16 views
Problem: I am a novice Java programmer who started learning to program in Java just a few weeks ago. I got an assignment from my tutor in which I have to write a program that prints the sum of the elements of a given array. The output of the program should be ... } I am allowed to take help from the Internet so asking for help from you guys. Can anybody please provide me with a solution? Thanks!
asked Dec 29, 2020 Code Learner 5.5k points
0 votes
1 answer 80 views
80 views
Problem : java does not limit the number of dimensions that an array may have
asked Nov 1, 2019 peterlaw 6.9k points
0 votes
1 answer 11 views
11 views
I have a blog website. In this website in several blogs. so from these blog post i need to remove duplicate elements from an array.
asked Sep 28, 2020 Daniel Anderson 4k points
0 votes
1 answer 510 views
510 views
I am getting an issue where my deployable jar hits an exception : can not deserialize instance of java.lang.string out of start_object token
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 65 views