I'm testing a piece of code
public class test { public static void main(String[] args) { String[] strArray = {"111", "222", "333", "444", "555"}; String strTmp1 = null; for (int i = 0; i < strArray.length; i++){ String strTmp = strArray[i]; strTmp1 = strTmp1 + " " + strTmp; } System.out.println(strTmp1); } } at the exit
null 111 222 333 444 555 How to remove null
+with lines creates a new line in memory, so in real life your code, to put it mildly, is not quite good. StringBuilder allows you to make strings avoiding this problem. - Andrei Kurulyov 5:56 pm