subject

Write a method called extractOddIndexes() that constructs and returns a new List of ints 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 < 77; i+=3) { list2.add(i) for(int i = 0; i < 20; i+=2) list2.add (i) System. out. println("Before:" + list2); listlv2 = extractOddIndexes (list2); System. out. println("After: " + list2); System. out. println("After2: " + list2v2);

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 13:30
Me ! evelyn is a manager in a retail unit. she wants to prepare a report on the projected profit for the next year. which function can she use? a. pmt b. round c. division d. what-if analysis
Answers: 2
question
Computers and Technology, 24.06.2019 09:50
Create a string list. 2. use console.readline() to collect values of firstname, lastname, street, city, state, zip, save them to list. 3. write a simple linq statement, call method uppercasewords() to change first letter to uppercase. 4. create a foreach statment to display the information. public static string uppercasewords(string value) { char[] array = value.tochararray(); if (array.length > = 1) { if (char.islower(array[0])) { array[0] = char.toupper(array[0]); } } for (int i = 1; i < array.length; i++) { if (array[i - 1] == ' ') { if (char.islower(array[i])) { array[i] = char.toupper(array[i]); } } } return new string(array);
Answers: 3
question
Computers and Technology, 24.06.2019 17:50
Acontact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. write a program that first takes in word pairs that consist of a name and a phone number (both strings). that list is followed by a name, and your program should output that name's phone number.
Answers: 1
question
Computers and Technology, 24.06.2019 18:30
How does the use of e-mail benefit business communications? it can be sent at any time. it is faster than regular mail. it improves writing skills. it is less expensive than using a courier. it reduces the need for proofreading.
Answers: 1
You know the right answer?
Write a method called extractOddIndexes() that constructs and returns a new List of ints that contai...
Questions
question
Mathematics, 22.01.2021 22:40
question
Mathematics, 22.01.2021 22:40
question
Mathematics, 22.01.2021 22:40
question
Mathematics, 22.01.2021 22:40
question
Physics, 22.01.2021 22:40
question
History, 22.01.2021 22:40
question
Mathematics, 22.01.2021 22:40
question
Social Studies, 22.01.2021 22:40
Questions on the website: 13722360