Skip to content

Instantly share code, notes, and snippets.

@alexandreaquiles
Created November 22, 2017 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandreaquiles/b687a1d258fb7f1d464ab8314f08a581 to your computer and use it in GitHub Desktop.
Save alexandreaquiles/b687a1d258fb7f1d464ab8314f08a581 to your computer and use it in GitHub Desktop.
Warning when _ used as an identifier in Java 8. Compilation error in Java 9 (though, bytecode from Java 8 is executed).
alexandre ~/keyword $ /usr/lib/jvm/java-8-oracle/bin/javac Keyword.java
Keyword.java:3: warning: '_' used as an identifier
int _ = 1;
^
(use of '_' as an identifier might not be supported in releases after Java SE 8)
Keyword.java:4: warning: '_' used as an identifier
System.out.println(_);
^
(use of '_' as an identifier might not be supported in releases after Java SE 8)
2 warnings
alexandre ~/keyword $ /usr/lib/jvm/java-8-oracle/bin/java Keyword
1
alexandre ~/keyword $ /usr/lib/jvm/java-9-oracle/bin/java Keyword
1
alexandre ~/keyword $ /usr/lib/jvm/java-9-oracle/bin/javac Keyword.java
Keyword.java:3: error: as of release 9, '_' is a keyword, and may not be used as an identifier
int _ = 1;
^
Keyword.java:4: error: as of release 9, '_' is a keyword, and may not be used as an identifier
System.out.println(_);
^
2 errors
public class Keyword {
public static void main(String[] args) {
int _ = 1;
System.out.println(_);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment