CJCoding With Joseph
15per day
← Back to Question List
Java Code Walkthrough #1

String Concatenation in a Loop

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 →