Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/java/grammar/for/for.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/java/grammar/for/for.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/grammar/for/for.html on line 2
Javaのfor文 | Java | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/grammar/for/for.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/grammar/for/for.html on line 17
Javaのfor文
Javaのfor文についての記述方法は多言語と同じです。
以下、サンプルです。

package purejava;

public class Sample {

    public static void main(String[] args) {
        
    public static void main(String[] args) {
        for(int i = 0; i < 3 ; i++){
            System.out.println(i);
        }
    }

}
実行結果は以下の通りです。

1
2
3
for文ではbreakやcontinueを使うことができます。Javaはラベル付きfor文を使うことができます。
for文が入れ子の場合、中にあるfor文でbreakすると、そのfor文からbreakするだけですが、ラベルを付けるとそのラベル箇所に対してbreak,continueすることが可能です。
以下、EXITというラベルを使ったサンプルです。

package purejava;

public class Sample {

    public static void main(String[] args) {
        EXIT:for(int i = 0; i < 3 ; i++){
            for(int j = 0; j < 3 ; j++){
                System.out.println(j);
                if(j == 1) break EXIT;
            }
        }
    }

}
実行結果は以下の通りです。

0
1

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/grammar/for/for.html on line 101

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/grammar/for/for.html on line 101

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/java/grammar/for/for.html on line 110

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/java/grammar/for/for.html on line 110