All pastes #261219 Raw Edit

Stuff

public java v1 · immutable
#261219 ·published 2006-11-29 00:54 UTC
rendered paste body
//Program Name: LinkedListReverser//Purpose: to use the methods available in the Sun Java LinkedList class//to reverse the order of a linked list.import java.util.LinkedList;public class LinkedListReverser{	private static final int MAX = 10;		public static void main(String[] args){		LinkedList<String> staff = new LinkedList<String>();		String[] staffNames = {"Arnie","Sinatra","Glenn","Wolfgang", "Amadeus"};//...and these are a few of my favorite things ...		int j;		for(j=0;j<staffNames.length;j++){			staff.addFirst(staffNames[j]);		}		ListIterator<String> goThrough = staff.listIterator(0);		//just to make sure that we got the list correctly made ... 		for(j=0;j<staffNames.Length;j++){			System.out.print(staff.next() + ", ");		}					}		public void reverseList(LinkedList<String> staff){		LinkedList<String> emily = new LinkedList<String>(); //see Emily Play ... Pink Floyd anyone?		for (String Person: staff) 			emily.addFirst(Person); 		staff.clear(); 		for (String Person: emily) 			staff.addLast(Person); 	}}