Storing First Case Variables from a String Expression (ArrayList to Array)
<p>I'm working on storing the first case of a variable into an array, since I do not know how many variables there will be I decided to use an array list.</p>

<p>I am getting the following error when compiling:</p>

<pre><code>javac TruthTester.java
TruthTester.java:102: error: no suitable method found for toArray(char[])
char[] charArr = letters.toArray(x);
^
method ArrayList.&lt;T&gt;toArray(T[]) is not applicable
(inferred type does not conform to declared bound(s)
inferred: char bound(s): Object)
method ArrayList.toArray() is not applicable
(actual and formal argument lists differ in length)
where T is a type-variable:
T extends Object declared in method &lt;T&gt;toArray(T[])
1 error
</code></pre>

<p>Here's my segment of code..</p>

<pre><code>private static char[] getVariables(String[] lines)
{
    ArrayList&lt;Character&gt; letters = new ArrayList&lt;Character&gt;();

    int count = 0;
    for(int x = 0; x &lt; lines.length; x++)
    {
        for(int i = 0; i &lt; lines[x].length(); i++)
        {
            char tempStore = 'a';
            boolean isCopy = false;
            int counter = 0;
            for(char letter : letters)
            {
                if(isAlphabeticToken(letter)){
                    if(lines[x].charAt(counter) == letter)
                    {
                        isCopy = true;
                    }
                    else
                    {
                        isCopy = false;
                        tempStore = letter;
                    }
                }
                else
                {
                    isCopy = true;
                }
                counter++;
            }
            if(!isCopy)
            {
                letters.add(tempStore);
                count++;
            }
        }
    }
            /*
             * ==========
             * ERROR HERE
             * ==========
             */
    char[] x = new char[letters.size()];
    char[] charArr = letters.toArray(x);

    return charArr;
}
</code></pre>
