title: Java: Find closest number in some collection
body: <p>I have a static set of ordered numbers {1, 2, 4, 10, 14, 20, 21,24, 29, 30} that can be stored in any collections. If a new number is passed in, I need to be able to find the nearest greater number to the new number.</p>
  
  <p>For example: 
  If my static set of ordered number is {1, 2, 4, 10, 14, 20, 21,24, 29, 30}. 
  The number passed in is 23, the closest greater number is 24.</p>
  
  <p>I thought about storing the static numbers into an array. Looping the array and then trying to find the closest number but this solution is O(n). Is there a quicker way?</p>