How to implement a sequential tree traversal in Java? (TreeSet)
Closed due to the fact that the essence of the issue is incomprehensible to the participants vp_arth , Mikhail Vaysman , rjhdby , Yuri , Harry March 18 '17 at 10:12 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
|
1 answer
You were correctly told about the iterators. Set (TreeSet) sets implement the basic Collection interface, which in turn implements Iterable. This means that you can iterate for each
Set<String> ts = new TreeSet<>(); ts.add("s1"); ts.add("s0"); for (String s : ts) { System.out.println(s); } |
for each- JVic