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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started