LoginSignup
2
2

More than 5 years have passed since last update.

[Java] if文でのEmpty Statement

Last updated at Posted at 2014-02-01

http://medium.com/on-coding/3fcb28e30ef3
を参考に

if (done)
; // Empty statement
else
System.out.println("Not done yet.");

boolean done = true;
の場合はなにもせず、
boolean done = false;
の場合は"Not done yet"をプリント

だがー? それよりも・・・

if (!done)
    System.out.println("Not done yet.");

まあ、trueのときは何もしないので、falseのときの処理だけ書いてあげれば良い、ということでおk?

コメントでのご指摘、ありがとうございますー。

2
2
2

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
2
2