I found out that Java supports constant folding of primitive types, but what about String
s?
Example
If I create the following source code
out.write(""
+ "<markup>"
+ "<nested>"
+ "Easier to read if it is split into multiple lines"
+ "</nested>"
+ "</markup>"
+ "");
What goes into the compiled code?
Combined Version? out.write("<markup><nested>Easier to read if it is split into multiple lines</nested></markup>");
Or the less efficient run-time concatenation version? out.write(new StringBuilder("").append("<markup>").append("<nested>").append("Easier to read if it is split into multiple lines").append("</nested>").append("</markup>").append(""));