SHARE
TWEET

Untitled

advictoriam Jan 16th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ArrayOps
  2. {
  3.    /**
  4.       This method accepts and integer array as a parameter, and then
  5.       returns the "middle" value of the array.
  6.       For an array of odd length, this would be the actual middle value.
  7.       For an array of even length, there are TWO middle values, so only
  8.       the first of the two values is returned.
  9.       @param values, an array of integers
  10.       @ return, the "middle" element of the array
  11.    */
  12.    public static int middleArray(int values[])
  13.    {
  14.       return values[(values.length%2 != 0) ? values.length/2 : values.length/2 - 1];
  15.    }
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top