Code example for ListIterator

Methods: hasNexthasPreviousnextnextIndexpreviouspreviousIndex

0
    multimap.put("foo", 1); 
    multimap.put("foo", 3); 
    List<Integer> list = multimap.get("foo"); 
    ListIterator<Integer> iterator = list.listIterator(); 
 
    assertFalse(iterator.hasPrevious()); 
    assertTrue(iterator.hasNext()); 
    assertEquals(0, iterator.nextIndex()); 
    assertEquals(-1, iterator.previousIndex()); 
 
    assertEquals(1, iterator.next().intValue()); 
    assertEquals(3, iterator.next().intValue()); 
    assertTrue(iterator.hasPrevious()); 
    assertFalse(iterator.hasNext()); 
 
    assertEquals(3, iterator.previous().intValue()); 
    assertEquals(1, iterator.previous().intValue()); 
  } 
 
  /** 
   * Test ListIterator methods that change the multimap. 
   */ 
Contextual code suggestions in your IDE  Get Codota for Java