title: IndexOutOfBounds, but why?
body: <p>I'm writing an app's code and when I enter only 2 numbers I get indexoutofbounds Length=2 Index=2. Why is this/how can I circumvent it?
  Here is my code:</p>
  
  <pre><code>        Arrays.sort(newNums);
          double median = 0;
          if(newNums.length%2!=0){
              median = (double) newNums[newNums.length/2];
          }else if(newNums.length%2==0){
              median = ( (double) newNums[newNums.length/2 + 1] + (double) newNums[newNums.length/2-1] )/2;
          }else{
  
          }
          String medianString = Double.toString(median);
          showDialog(medianString, type,"Median:");
  </code></pre>