If statement in for loop
<p>I have an arraylist of integer arrayslists and an arraylist of names. I'd like to add a certain number to one of those integer arraylists when it corresponds with a particular name and add a 0 to every other arraylist. I think that what I have should work, but it simply adds a 0 to everything and ignores the special case when the name is right. "Rating" is an integer, and "user" is a string. "Names" is an arraylist of strings. The language is Java.</p>

<pre><code>for(int i = 0; i&lt;names.size(); i++)
            {   

                if (names.get(i)==user)

                    allratings.get(i).add(rating);

                if (names.get(i)!=user) 

                    allratings.get(i).add(0);
            }   
</code></pre>

<p>Is there something wrong with my syntax? When I insert a print line, I find that my names arraylist and my allratings arraylist are perfectly matched up. Where am I going wrong?</p>
