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

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • 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 array
      lower - lower limit
      upper - 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 array
      result - 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 array
      lower - lower limit
      upper - 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)")