Question: in java Write a method named range that takes an array of integers as a parameter and returns the range of values contained in the


in java
Write a method named range that takes an array of integers as a parameter and returns the range of values contained in the array. The range of an array is defined to be one more than the difference between its largest and smallest element. For example, if the largest element in the array is 15 and the smallest is 4, the range is 12. If the largest and smallest values are the same, the range is 1. The followings show some calls to the method and their results: into al = {15, 22, 8, 19, 31); range (al) returns 24 int[] a2 = {3, 10000000, 5, -29, 4); range (a2) returns 10000030 inta3 = {100, 5); range (a3) returns 96 int[] a4 = (32): range (a 4) returns 1 You may assume that the array contains at least one element that its length is at least 1). You should not make any assumptions about the values of the particular elements in the array; they could be extremely large, very small, etc. You should not modify the contents of the array
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
