Question: Java: ArrayList using a wrapper class Write a class with a main() method. The main() method should declare and initialize four different ArrayLists, each containing
Write a class with a main() method. The main() method should declare and initialize four different ArrayLists, each containing at least four int values. The class should also contain a method named allTwoSeven. Given an ArrayList of ints, the allTwoSeven should return the int 19 if every element of the given ArrayList is either a 2 or a 7; otherwise, it should return 7. Here are some example method calls you can use to test your method: - alliwoseven ([4,5,2,7]) should return 7 - alliwoSeven ([2,7,7,2]) should return 19 - allTwoSeven ([6,9,8]) should return -7 - allTwoSeven ([2,2,2,2]) should return 19 There should be four calls to the allTwoSeven method in the main() method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
