Adding/Appending elements to an array - Java
<p>I am building a method which takes as argument, an array of decimal numbers, and a decimal threshold. The method should output all numbers from the list that are greater than the threshold.</p>

<p>My plan is to execute a for loop and examine each number in the array, and if that number (i) is greater than the threshold (x), to append to my result list. My problem is that I'm unable to add/append to the result list. </p>

<p>I have <code>System.out.println("Nothing here");</code> just to help me see if it's actually going through the  for loop or not, but my IDE is saying that calling <code>list.add(a[i]);</code> is wrong. I am a beginning programmer and not sure on how to fix this. Here is my code:</p>

<pre><code>public class a10 {

    public static void main(String[] args) {
        double a[] = {42, 956, 3,4};
        threshold(a, 2);
    }

    public static void threshold(double[] a, double x){
        double list[] = {};

        for (double i:a){
            if (i&lt;22){
                list.add(a[i]);
            }else{
                System.out.println("Nothing here");
            }
    }
}
</code></pre>
