Question: Generic Class Assignment. Can anyone help me? Implement a generic class that: has a type parameter called S o S should be type-bound to classes

Generic Class Assignment. Can anyone help me? Implement a generic class that: has a type parameter called S o S should be type-bound to classes that implement the Comparable interface has two private instance variables of type S has a constructor that accepts two arguments and assigns them to the instance variables has an overridden toString() method that outputs the values of the two instance variables has a findMax() method that returns the higher of the two instance variables o findMax must invoke compareTo() Implement a second class that: contains a main method instantiates the first class with two different specific types and different values uses the two objects to invoke each of the two instance methods in the first class

this is the code I got so far ********************************************************

public class GenericSType {

public static int findIndex(S value, S[] element) {

for (int i = 0; i < element.length; i++)

if (element [i] == value) {

return i;

}

return -1;

}

public static void main(String[] args) {

Integer[] Array1 = {6,12,39,98};

Double[] Array2 = {5.3,6.8,9.1,11.3};

String[] Array3 = {"purple","green", "black","grey","red","brown"};

System.out.println(findIndex(12, Array1));

System.out.println(findIndex(5.4, Array2));

System.out.println(findIndex("brown", Array3));

}

}

class Main {

private String Color;

private String Double;

When I get to the second half of this I get super lost can anyone help?

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 Databases Questions!