Question: Part I: Write a routine in Java that takes an array, the length of the array, and an element and returns the position of the

Part I: Write a routine in Java that takes an array, the length of the array, and an element and returns the position of the element in the array. For example, given the array with values [2, 4, 6, 8] and element 6, the routine should return 2 (since counting from 0, 6 occurs at position 2 in the array). Your routine should use generics to enable your routine to be reusable for different element types. Be sure to test your code with a Java compiler before you submit it.

Part II: Write a generic greater-than function that (a) takes two objects as arguments, each of which has a value method which returns an integer; and (b) returns the argument whose value method returns the larger integer. Your generic function should constrain its type argument so that types without a value method cannot be used.

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!