Question: Write a main method Write a method called extractOddIndexes that constructs and returns a new List of values that contains the sequence formed by removing

Write a main method

Write a main method Write a method called extractOddIndexes that constructs andreturns a new List of values that contains the sequence formed by

Write a method called extractOddIndexes that constructs and returns a new List of values that contains the sequence formed by removing the values at odd indexes in an existing List of values. For example, suppose that a List called list1 stores the following sequence of values: list1 = [13, 5, 7, 12, 42, 8, 23, 31] If we make the following call on the method: List result = extractOddIndexes (list1); After the call, list1 and result would store the following: listi : [13, 7, 42, 23] result : [5, 12, 8, 31] Notice that the values that were at odd indexes have been moved to the new List in the same order as in the original list and that the list now stores just values that were at even indexes also in the same order as in the original list. The list might have an odd number of values, as in: list2 = [14, -64, 16, 88, 21, 17, -93, 81, 17] in which case the lists would store the following after the call: list2 : (14, 16, 21, -93, 17] result : [-64, 88, 17, 81] Notice that list stores five values while result stores only four. List list1 = new LinkedList(); List list2 = new ArrayList(); List listlv2; List Integer> list2v2 ; listi.add (13); listi.add(5); listi.add (7); listi.add (12); listi.add (42); listi.add(8); listi.add (23); listi.add (23); listl.add(31); System.out.println("Before:" + listi); listlv2 = extractoddIndexes (list1); System.out.println("After: " + list1); System.out.println("After2: " + listlv2); for (int i = 1; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!