title: Find to closest higher and lower number in an array
body: <p>Heyo,</p>
  
  <p>I´m actually try to implement a function that takes an integer as input.
  I´ve also have an array of ascendent integer numbers.</p>
  
  <p>Now i´ve try to find the closest lower and closest higher number to my single integer.</p>
  
  <p>I´ve like to return it as an array but I´ve only found a solution to find THE one closest number to a given input.</p>
  
  <pre class="lang-java prettyprint-override"><code>public int getClosestTimeValue(int time) {
  int nearest = -1;
  int bestDistanceFoundYet = Integer.getInteger(null);
  int[] array = null;     
  // We iterate on the array...
  for (int i = 0; i &lt; array.length; i++) {
       // if we found the desired number, we return it.
  if (array[i] == time) {
      return array[i];
      } else {
          int d = Math.abs(time - array[i]);
  if (d &lt; bestDistanceFoundYet) {
      nearest = array[i];
  }
      }
  }
      return nearest;
  }
  </code></pre>
  
  <p>Has anyone an idea how I can solve this problem in java?</p>
  
  <p>Thank you, Lucas</p>