Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print out individual Strings from Iterable<String>

Tags:

java

iterable

I am having trouble printing out individual Strings from Interable object. I have this given function prefixMatch(String someword) that returns Iterable (that keeps a LinkedList of Strings, I think). I have tried turning it into a list but it wont work. Dose anyone know how to get the Strings out of it one by one?

tst is a Ternary search tree

Iterable<String> words = tst.prefixMatch(word);
like image 516
user1303750 Avatar asked Mar 30 '12 16:03

user1303750


1 Answers

If it's Iterable you can do an extended for on it.

Iterable<String> iterable;
for(String s : iterable){
    //Do whatever you want
}

Resources:

  • Oracle.com - The foreach loop

Related topics:

  • What is the Iterable interface used for?
like image 87
Colin Hebert Avatar answered Oct 13 '22 10:10

Colin Hebert