Java 9では1文字アンダースコア(_
)はキーワード(keyword)に変更され、変数名などに利用するとコンパイルエラーになる。Java 8以前は非推奨の識別子(identifier)であり、コンパイル時の警告メッセージにとどまっていた。
class UAAK { public static void main(String[] args) { int _ = 42; } }
warning: '_' used as an identifier
(use of '_' as an identifier might not be supported in releases after Java SE 8)
error: as of release 9, '_' is a keyword, and may not be used as an identifier
関連URL