Determining an arrays value depending on another array
<p>I'm currently working on one of my assignments, and am looking for some help with the logic for one of my functions.</p>

<p>First off I have a array of numbers to be categorized, then a number interval, this number determines in which position each of the numbers being plotted goes into array2.</p>

<p>ie. </p>

<pre><code>int interval = 2;

for(int i = 0; i &lt; array1.length; i++) {
    if((array1[i] &gt; 0) &amp;&amp; (array1[i] &lt; interval)) {
        array2[0]++;
    }
}
</code></pre>

<p>However, the number from array1 is 3. I would then need another if statement like so:</p>

<pre><code>...
}else if((array1[i] &gt; 2) &amp;&amp; (array1[i] &lt; interval * 2)) {
    array2[1]++;
}else if((array1[i] &gt; 
</code></pre>

<p>As you can start to see the problem with this is that I would need to continue for an infinite range of numbers. So my question is what is an easier way of achieving this goal? Or is there already a library which I can utilize to do so?</p>

<p>I'm sorry if I didn't make this clear enough, also I would prefer if code wasn't given to me. I would appreciate if someone would be able to tell me a more effective way about going about this, thanks in advance!</p>

<p>EDIT:</p>

<p>Assuming that the interval is set to 2, and the numbers from array1 are between 0 and 10, I would need to create a code that would do such:</p>

<pre><code>2 &lt; numFromArray1 &gt; 0 == array2[0]++
4 &lt; numFromArray1 &gt; 2 == array2[1]++
6 &lt; numFromArray1 &gt; 4 == array2[2]++
8 &lt; numFromArray1 &gt; 6 == array2[3]++
10 &lt; numFromArray1 &gt; 8 == array2[4]++
</code></pre>

<p>However, the numbers from array1 can be positive or negative, whole or decimal.</p>
