CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

String Concatenation in a Loop

Java code walkthrough · Question 1
easyLoops

Code

Read carefully. What does this print?
1public class Main {
2 public static void main(String[] args) {
3 String result = "";
4 for (int i = 1; i <= 3; i++) {
5 result += i + " ";
6 }
7 System.out.println(result.trim());
8 }
9}

Your answer

Next