import java.util.ArrayList; import java.util.List; import java.util.Random; import javax.swing.JOptionPane; /* * ListRecursionExercise.java * * Created on October 2, 2005, 4:40 PM * */ /** * * @author Bill Kraynek */ public class ListRecursionExercise { int indexOf(List l, Object x) { // your code goes here // use subList instead of a helper return -1; }// end indexOf List reverse(List l) { // your code goes here // use subList instead of a helper return null; }// end reverse /** Creates a new instance of ListRecursionExercise */ public ListRecursionExercise() { Random r = new Random(); List list = new ArrayList(); for( int i = 0; i < 10; i++ ) { list.add(r.nextInt(100)); } // end for String out = ""; out += "Index of 37 is " + indexOf(list,37) + "\n"; list.add(37); out += "Index of 37 is " + indexOf(list,37) + "\n"; out += list + "\nreversed is\n" + reverse(list) + "\n"; JOptionPane.showMessageDialog(null,out); } /** * @param args the command line arguments */ public static void main(String[] args) { new ListRecursionExercise(); } }