Package sysImplementation
Class Utilities
java.lang.Object
sysImplementation.Utilities
public class Utilities
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description Utilities()
-
Method Summary
Modifier and Type Method Description static int[]
getArrayElemsInRange(int[] array, int lower, int upper)
Returns an array with values in the range defined by lower (inclusive) and upper (inclusive).static int
getCountInRange(int[] array, int lower, int upper)
Returns the number of values in the range defined by lower (inclusive) and upper (inclusive)static int
getEvens(int[] array, int[] result)
Initializes the out parameter result with even values found in array
-
Constructor Details
-
Utilities
public Utilities()
-
-
Method Details
-
getCountInRange
public static int getCountInRange(int[] array, int lower, int upper)Returns the number of values in the range defined by lower (inclusive) and upper (inclusive)- Parameters:
array
- integer arraylower
- lower limitupper
- upper limit- Returns:
- Number of values found
- Throws:
java.lang.IllegalArgumentException
- if array is null or lower is greater than upper Any error message is fine (e.g., "Invalid parameters(s)")
-
getEvens
public static int getEvens(int[] array, int[] result)Initializes the out parameter result with even values found in array- Parameters:
array
- integer arrayresult
- integer array- Returns:
- Number of even values found
- Throws:
java.lang.IllegalArgumentException
- if array or result (or both) are null, or if result's length is less than array's length. Any error message is fine (e.g., "Invalid parameters(s)")
-
getArrayElemsInRange
public static int[] getArrayElemsInRange(int[] array, int lower, int upper)Returns an array with values in the range defined by lower (inclusive) and upper (inclusive). Feel free to use the getCountInRange method during the implementation of this method.- Parameters:
array
- integer arraylower
- lower limitupper
- upper limit- Returns:
- array with even values or empty array
- Throws:
java.lang.IllegalArgumentException
- if array is null or lower is greater than upper. Any error message is fine (e.g., "Invalid parameters(s)")
-