home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 October A / Pcwk10a98.iso / Inprise / TRIAL / JBUILDER / JSAMPLES.Z / SList6.java < prev    next >
Text File  |  1998-05-08  |  891b  |  34 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2. import com.objectspace.jgl.*;
  3.  
  4. /**
  5.  * Splicing a piece of a SList into another.
  6.  *
  7.  * @see com.objectspace.jgl.SList
  8.  * @version 3.0.0
  9.  * @author ObjectSpace, Inc.
  10.  */
  11.  
  12. public class SList6
  13.   {
  14.   public static void main( String[] args )
  15.     {
  16.     SList list1 = new SList();
  17.     list1.add( "apple" );
  18.     list1.add( "banana" );
  19.     SList list2 = new SList();
  20.     list2.add( "lotus" );
  21.     list2.add( "ferrari" );
  22.     list2.add( "lamborghini" );
  23.     System.out.println( "before: list1 = " + list1 + ", list2 = " + list2 );
  24.  
  25.     SListIterator i = list1.begin();
  26.     i.advance();
  27.     SListIterator start = list2.begin();
  28.     SListIterator finish = list2.begin();
  29.     finish.advance( 2 );
  30.     list1.splice( i, list2, start, finish );
  31.     System.out.println( "after: list1 = " + list1 + ", list2 = " + list2 );
  32.     }
  33.   }
  34.