Underscore is a ‘KEYWORD’ now since Java 9

Since Java 9, the purpose of using ‘Underscore’ has been changed. With any version before Java 9, It can be used to create a variable or as an identifier. But, NO MORE. In Java 9, ‘Underscore’ is a keyword. In this article, we are going to see how it’s usage changed through various versions. 


Check out: Iterate / ofNullable operations in Java 9 Stream

Underscore is a KEYWORD now since Java 9...!!! Click To Tweet

Usage in Java 7

In Java 7, it could be used to used as an identifier or creating variable. Below code will compile & execute completely fine.



Usage in Java 8

In Java 8, Oracle developers added the warning message that will be displayed when we execute the below code. Below code will compile perfectly fine but will show the warning message on execution.



Usage in Java 9

In Java 9, ‘Underscore’ is a keyword therefore below code won’t compile and will throw the error message. 



Underscore is a KEYWORD now since Java 9...!!! Click To Tweet

Do you like this Post? – then check my other helpful posts:

Other Useful References:


Related Posts:

[wcp-carousel id=”5342″]

Promotional Content:

Loading RSS Feed

Leave a Reply

Your email address will not be published.Required fields are marked *

Facebook Twitter Instagram YouTube