Java and C# pass by value differences
<p>I think the code below will make my question clear. If they both pass by value, why are they different. </p>

<p>C# below:</p>

<pre><code>static void Main(string[] args)
    {
        var list = new List&lt;int&gt; {1, 2, 3,};
        ChangeVars(list);
        foreach (var i in list)
        {
            Console.WriteLine(i);
        }
        Console.Read();
    }

    private static void ChangeVars(List&lt;int&gt; list)
    {
        for(int i = 0; i &lt; list.Count; i++)
        {
            list[i] = 23;
        }
    }
</code></pre>

<p>Returns 23, 23, 23, </p>

<p>Java below:</p>

<pre><code>public static void main(String[] args)
{
    List&lt;Integer&gt; goods = new ArrayList&lt;Integer&gt;();
    goods.add(1); goods.add(2); goods.add(3);
    ChangeThings(goods);

    for(int item: goods)
    {
        System.out.println(item);
    }
}

private static void ChangeThings(List&lt;Integer&gt; goods)
{
    for(int item: goods)
    {
        item = 23;
    }
}
</code></pre>

<p>Returns 1, 2, 3.</p>

<p>I don't understand the discrepancy. </p>
