Write a method named removeEvens
that accepts a List
of integers as a parameter and removes the even values from the list, returning those values as a new list.
The new list's even values should be ordered in the same relative order as they appeared in the original list.
For example, if a list list1
contains [0, 17, 16, 7, 10, 14, 13, 12]
, and we make the following call:
List<Integer> list2 = removeEvens(list1);
Then after the call list1
and list2
would contain the following values:
list1: [17, 7, 13]
list2: [0, 16, 10, 14, 12]