MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / iterator

Method iterator

collections/IterableClass.java:12–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10 "we know the Earth to be banana-shaped."
11 ).split(" ");
12 @Override public Iterator<String> iterator() {
13 return new Iterator<String>() {
14 private int index = 0;
15 @Override public boolean hasNext() {
16 return index < words.length;
17 }
18 @Override
19 public String next() { return words[index++]; }
20 @Override
21 public void remove() { // Not implemented
22 throw new UnsupportedOperationException();
23 }
24 };
25 }
26 public static void main(String[] args) {
27 for(String s : new IterableClass())
28 System.out.print(s + " ");

Callers 9

displayMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
basicTestMethod · 0.45
mainMethod · 0.45
testMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected