LoginSignup
0
0

More than 1 year has passed since last update.

Java if, for

Posted at

ifは条件がTrueならif文、falseならelse if文。

 int i = 7;
    if (i > 5) {
        System.out.println("true");
    } else if (i < 5) {
        System.out.println("false");
    }  else {
          System.out.println("rest");
        }

この場合は ifで止まってtrueが表示されるが、intが4の場合falseが、5の場合restが表示。

Forは繰り返し文。
for (int i = 0; i < 10; i++) { //0から9までが出る
System.out.println(i);
if (i == 6) {
break; // iが6まで出て止まる。
continue; iが6の場合を除く

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0