Write a method that takes a List
of Integer and returns the int sum of the
numbers in the list.
Write a method that takes a List of String
values and returns the int count of the numbers of
occurrences of "pig" in the list.
Write a void method that takes a List
of String values replaces all the occurrences
of "cat" with "dog".
Write a void method that takes a List
of String values remove all the occurrences
of "frog".
Write a method that takes a List of String
and counts how many times "egg" immediately
precedes "chicken" and how many times "chicken"
immediately precedes "egg" and returns "egg" if
egg comes first more often; "chicken" if chicken comes first
more often; and "Nobody knows!" if they are tied.
A few List methods to practice with. Declare all your
parameters, return types, and variables using the interface
type List, not ArrayList. Since List
is an interface, when you need to make a new list you will still construct
an ArrayList, e.g. List<String> result = new
ArrayList<>();