Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

What are the basic financial decisions ?

Answered: 1 week ago

Question

What is meant by 'Wealth Maximization ' ?

Answered: 1 week ago