Question
1) Using wildcards, write a generic method that counts the number of even numbers in a List. This method should accept Lists with elements that
1) Using wildcards, write a generic method that counts the number of even numbers in a List. This method should accept Lists with elements that inherit from Integer.
2) Write the skeleton of a generic class called MyList. MyList represents a list that can be created to hold elements of type String (or subclasses of String). MyList should have the following methods: add (takes an element as input, returns nothing), remove (takes an element as input, returns nothing), indexOf (takes an element as input, returns an integer index), get (takes an integer index as input, returns an element). The skeleton of the class should contain the class definition (ex: class Test {}) and the method definitions (ex: void testMethod(int testInput)). Writing the implementation for the methods is unnecessary.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started