Question: Part 1 Write a static method that takes an array of a generic type as its only argument. The method should display the array and

Part 1
Write a static method that takes an array of a generictype as its only argument. The method should display the array and return the number of elements in the array. Test the method in main with at least three arrays of objects.
SAMPLE OUTPUT
Here is an Integer array
1221716813
That array held 6 elements
Here is a String array
one two three four
That array held 4 elements
Here is a Double array
1.12.23.34.45.5
That array held 5 elements
Part 2
public static double listAdder(ArrayList list){
???
}
Examine the listAdder method fragment above. Complete the method so that it displays the list elements all on one line and returns the sum of the elements. Demonstrate the method by calling it in main with ArrayLists of three different classes that extend class Number. The operator instanceofcan test for object type which would be necessary to have in a foreach loop for the data types types supported ( Integer , Byte and Double )
SAMPLE OUTPUT
1221716813
Integer list totals 77.0
1.12.23.34.45.56.6
Double list totals 23.1
122047
Byte list totals 43.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!