Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Concepts: Generics Arrays Objects Part I: Write a routine in Java that takes an array, the length of the array, and an element and returns

Concepts:

Generics

Arrays

Objects

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.

Submission:

The code and screenshots that demonstrate that you completed Part I and Part II.

Project files and Word document with pasted code and screenshots.

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

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

Analyse the process of new product of development.

Answered: 1 week ago

Question

Define Trade Mark.

Answered: 1 week ago