FileDocCategorySizeDatePackage
Iterators2.javaAPI DocExample1260Sat Sep 12 03:01:00 BST 1998None

Iterators2

public class Iterators2 extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    Array array = new Array();
    array.add( "magical" );
    array.add( "mystery" );
    array.add( "tour" );
    System.out.println( "before array = " + array );
    toUppercase( array );
    System.out.println( "after array = " + array );

    DList list = new DList();
    list.add( "magical" );
    list.add( "mystery" );
    list.add( "tour" );
    System.out.println( "before list = " + list );
    toUppercase( list );
    System.out.println( "after list = " + list );
    
static voidtoUppercase(Container container)

    // Obtain iterator positioned at first element.
    ForwardIterator iterator = container.start();

    // Obtain iterator positioned immediately after last element.
    ForwardIterator end = container.finish();

    // Loop through every element.
    while ( !iterator.equals( end ) )
      {
      String current = (String) iterator.get();
      // Replace current element with uppercase equivalent.
      iterator.put( current.toUpperCase() );
      iterator.advance(); // Move forward by one element.
      }