<p>What does Java do with long variables while performing addition?</p>

<p>Wrong version 1:</p>

<pre><code>Vector speeds = ... //whatever, speeds.size() returns 2
long estimated = 1l;
long time = speeds.size() + estimated; // time = 21; string concatenation??
</code></pre>

<p>Wrong version 2:</p>

<pre><code>Vector speeds = ... //whatever, speeds.size() returns 2
long estimated = 1l;
long time = estimated + speeds.size(); // time = 12; string concatenation??
</code></pre>

<p>Correct version:</p>

<pre><code>Vector speeds = ... //whatever, speeds.size() returns 2
long estimated = 1l;
long size = speeds.size();
long time = size + estimated; // time = 3; correct
</code></pre>

<p>I don't get it, why Java concatenate them.</p>

<p>Can anybody help me, why two primitive variables are concatenated?</p>

<p>Greetings, guerda</p>

I suspect you're not seeing what you think you're seeing. Java doesn't do this.
Please try to provide a
short but complete program
which demonstrates this. Here's a short but complete program which demonstrates correct behaviour, but with your "wrong" code (i.e. a counterexample).
```
```
import java.util.*;

public class Test
{
    public static void main(String[] args)
    {
        Vector speeds = new Vector();
        speeds.add("x");
        speeds.add("y");

        long estimated = 1l;
        long time = speeds.size() + estimated;
        System.out.println(time); // Prints out 3
    }
}
```
```