for (;;) { ループの処理 } または while (true) { ループの処理 }
- public class Combination02 {
- public static void main(String[] args) {
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (i < j) {
- break;
- }
- System.out.println(i + ", " + j);
- }
- }
- }
- }
□ 実行結果
$ java Combination02 0, 0 1, 0 1, 1 2, 0 2, 1 2, 2
- public class Combination03 {
- public static void main(String[] args) {
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (i == j) {
- continue;
- }
- System.out.println(i + ", " + j);
- }
- }
- }
- }
□ 実行結果
$ java Combination03 0, 1 0, 2 1, 0 1, 2 2, 0 2, 1
□ 実行結果
$ java Kuku04 30 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 5 10 15 20 25 30 6 12 18 24 30 7 14 21 28 8 16 24 9 18 27
□ 実行結果
$ java Kuku05 30 (空白行が出ます) 32 36 30 35 40 45 30 36 42 48 54 35 42 49 56 63 32 40 48 56 64 72 36 45 54 63 72 81
- public class Search01 {
- public static void main(String[] args) {
- char c = args[1].charAt(0); // コマンドラインの第2引数の1文字目を取得
- // ここにコードを記述してください。
- }
- }
□ 実行結果
$ java Search01 "Hello World" l 'l' は 'Hello World' の 3 番目の文字です。
- public class Search02 {
- public static void main(String[] args) {
- char c = args[1].charAt(0); // コマンドラインの第2引数の1文字目を取得
- // ここにコードを記述してください。
- }
- }
□ 実行結果
$ java Search02 "Hello World" l 'l' は 'Hello World' の 3 番目の文字です。 'l' は 'Hello World' の 4 番目の文字です。 'l' は 'Hello World' の 10 番目の文字です。
- public class Search03 {
- public static void main(String[] args) {
- char c = args[1].charAt(0); // コマンドラインの第2引数の1文字目を取得
- // ここにコードを記述してください。
- }
- }
□ 実行結果
$ java Search03 "Hello World" l 2 'l' は 'Hello World' の 4 番目の文字です。