Getting different output from main
<pre><code>package com.test.scjp;

import java.util.List;
import java.util.ArrayList;

public class TestGeneric {
    public static void main(String args[]){
        try{
            List&lt;String&gt; l = new ArrayList&lt;String&gt;();
            TestGeneric t = new TestGeneric();
        //t.test(l);
            System.out.println("Test");
            l=t.test(l);
            System.out.println("Test2");

            System.out.println(l.get(0));
        }
        catch(Exception e){
            e.printStackTrace();
        }
    }
    public List&lt;String&gt; test(List l){
        System.out.println("Test0");
        l.add(new Integer(1));
        System.out.println("Test1");
        return l;
    }
}
</code></pre>

<p>When I run this code 20 times I am getting different outputs:</p>

<p><strong>Output 1:</strong></p>

<pre><code>Test
Test0
Test1
Test2
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
    at com.test.scjp.TestGeneric.main(TestGeneric.java:16)
</code></pre>

<p><strong>Output 2:</strong></p>

<pre><code>Test
Test0
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
    at com.test.scjp.TestGeneric.main(TestGeneric.java:16)
Test1
Test2
</code></pre>
