Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vector speeds = ... //whatever, speeds.size() returns 2
- long estimated = 1l;
- long time = speeds.size() + estimated; // time = 21; string concatenation??
- Vector speeds = ... //whatever, speeds.size() returns 2
- long estimated = 1l;
- long time = estimated + speeds.size(); // time = 12; string concatenation??
- Vector speeds = ... //whatever, speeds.size() returns 2
- long estimated = 1l;
- long size = speeds.size();
- long time = size + estimated; // time = 3; correct
- 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
- }
- }
- System.out.println("" + size + estimated);
- "" + size <--- string concatenation, so if size is 3, will produce "3"
- "3" + estimated <--- string concatenation, so if estimated is 2, will produce "32"
- System.out.println("" + (size + estimated));
- "" + (expression) <-- string concatenation - need to evaluate expression first
- (3 + 2) <-- 5
- Hence:
- "" + 5 <-- string concatenation - will produce "5"
Add Comment
Please, Sign In to add comment