How to copy the values of an array in java into a new array excluding min and max values?
<p>I have a home work problem like this:</p>

<p>The following data represent Richter Scale data for earthquakes. Write a program to calculate and print the average of any valid earthquake data. </p>

<p>Store the Richter values in an array of doubles named quakeLevels. </p>

<p>Unfortunately, your seismograph is known to sometimes produce unreliable readings (like the value of 10.1 in this example). So you decide to throw out the maximum and minimum readings. </p>

<p>Your program should do the following:</p>

<ul>
<li>Declare and initialize the quakeLevels array using the following data. 
{ 5.6, 6.2, 4.0, 5.5, 5.7, 6.1,7.4, 8.5, 5.5, 6.3, 6.4, 2.1, 6.9, 4.3, 3.1, 7.0, 10.1 } </li>
<li>Determine the maximum and minimum values in the array. </li>
<li>Compute the average of the array contents, excluding the maximum and minimum values. </li>
<li>Print the values in the array excluding the maximum and minimum values. </li>
<li>Print the average. </li>
</ul>

<p>Complete your code below:</p>

<p>I have tried this problem with the following code but I am getting null values for the new array.</p>

<pre><code>public class QuakeLevels {


    public static void main(String[] args) {



        Double quakeLevels[] = { 5.6, 6.2, 4.0, 5.5, 5.7, 6.1,7.4, 8.5, 5.5, 6.3, 6.4, 2.1, 6.9, 4.3, 3.1, 7.0, 10.1 };
        Double minQuakeLevel = Double.MAX_VALUE;
        Double maxQuakeLevel = Double.MIN_VALUE;
        double totalQuakeLevels =0.0;
        double avgQuakeLevels =0.0;
        Double[] newQuakeLevels = new Double[(quakeLevels.length-2)]; //array excluding min and max value from the original
        for(int i=0;i&lt;quakeLevels.length;i++){
              totalQuakeLevels+=quakeLevels[i];
          if(quakeLevels[i]&lt;minQuakeLevel) {
                minQuakeLevel=quakeLevels[i];
          }
          if(quakeLevels[i]&gt;maxQuakeLevel){
                maxQuakeLevel =quakeLevels[i];
            }


        }



         avgQuakeLevels = ((double)totalQuakeLevels-(minQuakeLevel+maxQuakeLevel))/(quakeLevels.length-2); // Excluding min and max Quake Levels to calculate average
         System.out.printf("%s%.1f\n","Average Quake Level= ",avgQuakeLevels); 
         System.out.print("The new quake level:");
         for(int i=0;i&lt;quakeLevels.length-2;i++){

          if(newQuakeLevels[i]!=minQuakeLevel &amp;&amp; newQuakeLevels[i]!=maxQuakeLevel){
              quakeLevels[i]=newQuakeLevels[i];


         System.out.printf("%6s",newQuakeLevels[i]);
           }

         }
          System.out.println("");
        }
    }
</code></pre>
