Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How is CONCISENESS important in a business letter?

Answered: 1 week ago