Please help I can not see the error : <p>I am using Intellj Idea and I am playing with ArrayLists, Arrays and  a sorting algorithm I want to generate 5 random grades put them into an ArrayList convert the values of the ArrayList into an Array. Sort the Array values from least to greatest and print to screen the grades before and after sort here is what I have:</p>

<pre><code>    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.Arrays;


    public class Grades {




    public static void main(String args[])
{
    ArrayList &lt;Integer&gt; scores = new ArrayList&lt;Integer&gt;();

    for(int i = 0; i &lt; 5; i++)
    {

        scores.add((int) (Math.random() * 30 + 1));
    }
    for (int i =0; i &lt; scores.size();i++)
    {
        System.out.println(scores.get(i));
    }
    int arrayOne[] = new int[scores.size()];
    arrayOne = scores.toArray(new int[scores.size()]);
</code></pre>

<p>The last line is where I have the problem. Intellij says: no suitable method found for toArray(int[]). </p>

<p>Is my syntax wrong? </p>

<p>Did I forget to import a library?</p>

<p>Is it possible for ArrayLists and Arrays to interact in this way? </p>

<p>Please help. </p>

<pre><code>    int first,second, temp=0;

    for(first=0; first &lt; arrayOne.length -1; first++)
    {
        for (second = 0; second &lt; arrayOne.length - 1 - first; second++)
        {
            if(arrayOne[second] &lt; arrayOne[second +1])
            {
                temp = arrayOne[second];
                arrayOne[second] = arrayOne[second + 1];
                arrayOne[second+1] = temp;
            }
        }
    }
</code></pre>

<p>I haven't been able to run this bit to see if it sorts the way I want it too yet.</p>

<pre><code>    for(int i = 0; i &lt; arrayOne.length; i++)
    {
        System.out.println(arrayOne[i]);
    }


}
</code></pre>

<p>}</p>
