title: Java Possible Lossy Conversion Double to Int
body: <p>So this is my program which is linked to a driver program. I am having the problem possible lossy conversion and I understand where I am having it but I do not know how to fix it. I need to re-arrange a <code>Double[] array = new Double[20]</code> by ordering the numbers from lowest to highest as shown below. How can I do this correctly with out making significant changes to my program?</p>
  
  <pre><code>public void insert (double val){
    if(count &lt; 20){
      if(val &gt;= 1 || val &lt;= 10){
        array[count] = val;
        count++;
      }
    }                                  
  }
  
  double min;
  double max;
  double tmp;
  
  for(min = count - 1; min &gt; 0; min--){
     max = 0;
     for(int i = 1; i &lt;= min; i++){       // Error here because of the min value
        if(val[i] &gt; val[max]){          // Error here because of the max value
           max = i;
        }
     }
     if(max != min){
        tmp = val[max];                  // Error here because of the max value
        val[max] = val[min];            // Error here because of the min value
        val[min] = tmp;                  // Error here because of the min value
     }
  }
  </code></pre>