, , , - , . , - Java , , .
2 +, String, GC'd. , a = "1" b = "2", do String s = "s" + a + b;, Java String "s1", , "s12". , - StringBuilder. ( , .)
If you don't like string formatting , not just concatenation , use MessageFormator String.format(). It is prettier and avoids intermediate lines created using the operator +. So, something like String urlBase = "http://host/res?a=%s&b=%s"; String url = String.format(urlBase, a, b);where aand bare the parameters of the query string.
source
share