Question: hi, I have an interface which has a method that returns the index of smallest element in the array. the interface has
hi, I have an interface which has a method that returns the index of smallest element in the array.
the interface has
in the class of implemention has an generic array which defiend like this:
T Myarray[]; Myarray = (T[]) new Comparable[size]; # note : note sure if this way best way to create generic array
My question is how i can make the min method work for the generic array to make comparison, since every time it gives me an error: at java.lang.Integer.compareTo(Unknown Source), and how i can initialize the generic array in the main class with one parameter(the size).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
