Question 4 Generic Array Implement Generic Array Allow Data Specific Type Added Array Publ Q43809954
Java8 programming, generics,collections,interfaces; pleaseexplain in detail
Question 4: Generic Array You are to implement a generic array that will allow any only data of a specific type added to the array. public class GenericArray<T> { private T[] array; public GenericArray () { //initialise array here //Define your remaining methods The array must support the following operations: • long size (), returns the capacity of the array. • T set (int index, T element), sets an element in the array. • Tget (int index), returns an element at a specific index, should throw IndexOutOf- BoundsError if index is <0 or >= size(). • long resize (long newSize), returns the old size and resizes the array. Show transcribed image text Question 4: Generic Array You are to implement a generic array that will allow any only data of a specific type added to the array. public class GenericArray { private T[] array; public GenericArray () { //initialise array here //Define your remaining methods The array must support the following operations: • long size (), returns the capacity of the array. • T set (int index, T element), sets an element in the array. • Tget (int index), returns an element at a specific index, should throw IndexOutOf- BoundsError if index is = size(). • long resize (long newSize), returns the old size and resizes the array.
Expert Answer
Answer to Question 4: Generic Array You are to implement a generic array that will allow any only data of a specific type added to…
OR