Java がプリミティブ型の定数折りたたみをサポートしていることがわかりましたが、Strings はどうでしょうか。
例
次のソースコードを作成すると
out.write(""
+ "<markup>"
+ "<nested>"
+ "Easier to read if it is split into multiple lines"
+ "</nested>"
+ "</markup>"
+ "");
コンパイルされたコードには何が入りますか?
合体バージョン?out.write("<markup><nested>Easier to read if it is split into multiple lines</nested></markup>");
それとも、効率の悪いランタイム連結バージョンですか?out.write(new StringBuilder("").append("<markup>").append("<nested>").append("Easier to read if it is split into multiple lines").append("</nested>").append("</markup>").append(""));