### Question:
Path implements Iterable<String>, Serializable { public Iterator<String> iterator() { return new Iterator<String>() { final String[] elements = Path.this.elements; int nextIndex = 0; public boolean hasNext() { return nextIndex < elements.length; } public String next() { if (hasNext() == false) { throw new NoSuchElementException(); } return elements[nextIndex++]; } public void remove() { throw new UnsupportedOperationException("remove is not supported by this iterator"); } }; } Path();  Path(String pathStr); private  Path(String[] elements, String pathStr); Path getParent(); Path getSubPath(int fromPosition); Path getSubPath(int fromPosition, int length); int length(); Iterator<String> iterator(); Collection<String> getElements(); String getElement(int index); String getLastElement(); String toString(); String getPathString(); int hashCode(); boolean equals(Object obj); static Path parse(String pathStr); static String getPathString(Path path); static Path concat(Path... paths); static String toPathString(List<String> listOfStrings); static String toPathString(String[] strings); static final String THIS_PATH_ELEMENT; static final String PATH_SEPARATOR; static final char PATH_SEPARATOR_CHAR; }### Answer:
@Test public void iterate() { Path path = new Path("this.a.b.c"); Iterator<String> it = path.iterator(); assertEquals("it.hasNext()", true, it.hasNext()); assertEquals("it.next()", "a", it.next()); assertEquals("it.hasNext()", true, it.hasNext()); assertEquals("it.next()", "b", it.next()); assertEquals("it.hasNext()", true, it.hasNext()); assertEquals("it.next()", "c", it.next()); assertEquals("it.hasNext()", false, it.hasNext()); try { it.next(); fail("expected NoSuchElementException"); } catch (NoSuchElementException ex) { } }