public class Array
Modifier and Type | Method and Description |
---|---|
static double |
average(int[] arr)
This method will compute the average of all the elements in the parameter
array arr
|
static double |
average(int[] arr,
int firstIndex,
int lastIndex)
This method will compute the average of the elements in the parameter
array arr starting at index firstIndex and ending at
index lastIndex.
|
static int |
indexOfFirstMaxValue(int[] arr)
This method will search the elements in the parameter array arr for the index of the
first occurrence of the maximum value
|
static int |
indexOfFirstMaxValue(int[] arr,
int firstIndex,
int lastIndex)
This method will search the elements of the parameter array arr
starting at index firstIndex and ending at
index lastIndex for the index of the first occurrence of the maximum
value.
|
static int |
indexOfFirstMinValue(int[] arr)
This method will search the elements in the parameter array arr for the index of the
first occurrence of the minimum value
|
static int |
indexOfFirstMinValue(int[] arr,
int firstIndex,
int lastIndex)
This method will search the elements of the parameter array arr
starting at index firstIndex and ending at
index lastIndex for the index of the first occurrence of the minimum
value.
|
static void |
main(java.lang.String[] args) |
static int |
maxValue(int[] arr)
This method will find and return the element with the maximum value in the parameter
array arr
|
static int |
maxValue(int[] arr,
int firstIndex,
int lastIndex)
This method will search the elements in the parameter array arr,
starting at index firstIndex and ending at index lastIndex,
for the element with the maximum value.
|
static int |
minValue(int[] arr)
This method will find and return the element with the minimum value in the parameter
array arr
|
static int |
minValue(int[] arr,
int firstIndex,
int lastIndex)
This method will search the elements in the parameter array arr,
starting at index firstIndex and ending at index lastIndex,
for the element with the minimum value.
|
static int |
numberOfAboveAverageElements(int[] arr)
This method will scan count all of elements in arr
that are above the average of all the elements in the array.
|
static int |
numberOfAboveAverageElements(int[] arr,
int firstIndex,
int lastIndex)
This method will scan and count of elements in arr
starting at index firstIndex and ending at
index lastIndex that are above the average of the elements
in the specified range.
|
static int |
numberOfBelowAverageElements(int[] arr)
This method will scan and count all the elements in arr
that are below the average of all the elements in the array.
|
static int |
numberOfBelowAverageElements(int[] arr,
int firstIndex,
int lastIndex)
This method will scan and count of elements in arr
starting at index firstIndex and ending at
index lastIndex that are below the average of the elements
in the specified range.
|
static void |
reverseArray(int[] arr)
This method reverses all the elements in array arr.
|
static void |
rotateElements(int[] arr)
This method is used to rotate all the elements in arr
one position to the right.
|
static void |
rotateElements(int[] arr,
int rotationCount)
This method is used to rotate all the elements in arr
the specified rotationCount positions to the right.
|
static int |
sum(int[] arr)
This method will compute the sum of all the elements in the parameter
array arr
|
static int |
sum(int[] arr,
int firstIndex,
int lastIndex)
This method will compute the sum of the elements in the parameter
array arr starting at index firstIndex and ending at
index lastIndex.
|
public static int sum(int[] arr)
arr
- An array of int valuespublic static int sum(int[] arr, int firstIndex, int lastIndex)
arr
- An array of int valuesfirstIndex
- The index of the first element to include in the sumlastIndex
- The index of the last element to include in the sumpublic static double average(int[] arr)
arr
- An array of int valuespublic static double average(int[] arr, int firstIndex, int lastIndex)
arr
- An array of int valuesfirstIndex
- The index of the first element to include in the averagelastIndex
- The index of the last element to include in the averagepublic static int maxValue(int[] arr)
arr
- An array of int valuespublic static int maxValue(int[] arr, int firstIndex, int lastIndex)
arr
- An array of int valuesfirstIndex
- The index of the first element to include in the searchlastIndex
- The index of the last element to include in the searchpublic static int indexOfFirstMaxValue(int[] arr)
arr
- An array of int valuespublic static int indexOfFirstMaxValue(int[] arr, int firstIndex, int lastIndex)
arr
- An array of int valuesfirstIndex
- The index of the first element to include in the searchlastIndex
- The index of the last element to include in the searchpublic static int minValue(int[] arr)
arr
- An array of int valuespublic static int minValue(int[] arr, int firstIndex, int lastIndex)
arr
- An array of int valuesfirstIndex
- The index of the first element to include in the searchlastIndex
- The index of the last element to include in the searchpublic static int indexOfFirstMinValue(int[] arr)
arr
- An array of int valuespublic static int indexOfFirstMinValue(int[] arr, int firstIndex, int lastIndex)
arr
- An array of int valuesfirstIndex
- The index of the first element to include in the searchlastIndex
- The index of the last element to include in the searchpublic static int numberOfBelowAverageElements(int[] arr)
arr
- An array of int valuespublic static int numberOfBelowAverageElements(int[] arr, int firstIndex, int lastIndex)
arr
- An array of int valuesfirstIndex
- The index of the first element to include in the searchlastIndex
- The index of the last element to include in the searchpublic static int numberOfAboveAverageElements(int[] arr)
arr
- An array of int valuespublic static int numberOfAboveAverageElements(int[] arr, int firstIndex, int lastIndex)
arr
- An array of int valuesfirstIndex
- The index of the first element to include in the searchlastIndex
- The index of the last element to include in the searchpublic static void rotateElements(int[] arr)
arr
- An array of int valuespublic static void rotateElements(int[] arr, int rotationCount)
arr
- An array of int valuesrotationCount
- The number of times to rotate the array elements to the right.public static void reverseArray(int[] arr)
arr
- An array of int values