code: public static double[] createBoundingBox(double[][] input) {
          int maxActualCoords = Math.min(input[0].length, 3);// max 3, ignoring potential m values
          double[] result = new double[maxActualCoords * 2];
  
          for (int i = 0; i < maxActualCoords; i++) {
              result[i] = Double.MAX_VALUE;
          }
          for (int i = maxActualCoords; i < result.length; i++) {
              result[i] = - Double.MAX_VALUE;  // use negative Double.MAX_VALUE, Double.MIN_VALUE is NOT what you'd expect it to be!
          }
          for (double[] point : input) {
              for (int i = 0; i <  maxActualCoords; i++) {
                  result[i] = Math.min(point[i], result[i]);
                  result[i + maxActualCoords] = Math.max(point[i], result[i + maxActualCoords]);
              }
          }
          return result;
      }
docs: This method computes the boundingbox of a list of points (such as the coordinates of a multipoint or linestring)
  
  @param input a list of lists that each contain between two and for doubles (x, y and optional z and m coordinates)
  @return a list with doubles. the result is a 2*n array where n is the number of dimensions represented
  in the input (m doesn't count as a dimension), with the lowest values for all axes followed by the highest values.