4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Boolean.getBoolean(String)は便利

Posted at

booleanのオブジェクト型BooleanのgetBoolean(String arg)メソッドは、
Long.longvalue()
みたいにボクシング用と思いきや、
引数に入れたシステムプロパティのtrue/falseを判定してくれるという
メソッドでした。
つまり、eclipseなどの起動構成でVM引数に
-Dhogehoge.property.key=true
とでも入れておけば、ソース上から
Boolean.getBoolean("hogehoge.property.key")
の値trueが取れるわけです。

しかもキーがなかったり、あっても右辺値がtrueじゃない場合(変な文字列とか)
の場合はちゃんとfalseを返してくれます。(NullPointerExceptionじゃない)
デバッグ用に処理を分岐させたい時とか便利です。

やりすぎると謎オプションが増えて管理できなくなるかもですが。

4
5
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
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?