Please Show Screenshots Ide Make Sure Program Works Maximum Element Array Implement Follow Q37232522

Please show the screenshots in IDE to make sure the programworks.

(Maximum element in an array) Implement the following methodthat returns the maximum element in an array:

public static <E extends Comparable<E>> E max(E[ ]list)


Answer


public class GenericMaxComparable { public static <E extends Comparable<E>> E max(E[] list) { E maxValue = list[0]; for (int i = 0; i < list.length; i++) { if (list[i].compareTo(maxValue) > 0) {

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.