當在Java中如何在一個單獨的行打印:使用3個循環
public class Looping {
public static void main(String[] args) {
for(int a=1;a<=10;a++){
System.out.println (a); //
}
for(int a=1;a<=10;a++){
System.out.print (a); // print without spaces
}
// I need to know what code should go here to start the next loop in a new line
for(int a=1;a<=10;a++){
System.out.print (a+ " ");//print with spaces
}
}
}
結果是
1
2
3
4
5
6
7
8
9
10
123456789101 2 3 4 5 6 7 8 9 10
我想知道如何利用第三循環到新行。像下面一樣
1
2
3
4
5
6
7
8
9
10
12345678910
1 2 3 4 5 6 7 8 9 10
上面的兩行都做這個任務:)謝謝:* –