What does Java do with long variables while performing addition?
Wrong version 1:
Vector speeds = ... //whatever, speeds.size() returns 2
long estimated = 1l;
long time = speeds.size() + estimated; // time = 21; string concatenation??
Wrong version 2:
Vector speeds = ... //whatever, speeds.size() returns 2
long estimated = 1l;
long time = estimated + speeds.size(); // time = 12; string concatenation??
Correct version:
Vector speeds = ... //whatever, speeds.size() returns 2
long estimated = 1l;
long size = speeds.size();
long time = size + estimated; // time = 3; correct
I don't get it, why Java concatenate them.
Can anybody help me, why two primitive variables are concatenated?
Greetings, guerda