Let's say I have the following code:
String RET = System.getProperty("line.separator");
int x = 5, y = 3;
StringBuilder sb = new StringBuilder();
sb.append("Ship located at " + x + ", " + y + RET);
sb.append("Current time: " + System.nanoTime());
return sb.toString();
Will the compiler be smart and do this:
StringBuilder sb = new StringBuilder();
sb.append("Ship located at ");
sb.append(x);
sb.append(", ");
sb.append(y);
sb.append(RET);
sb.append("Current time: ");
sb.append(System.nanoTime());
return sb.toString();
Or will it be dumb and do this:
StringBuilder sb = new StringBuilder();
sb.append(new StringBuilder().append("Ship located at ").append(x).append(", ").append(y).append(RET).toString());
sb.append(new StringBuilder().append("Current time: ").append(System.nanoTime()).toString());
return sb.toString();
Or will it do something else?