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:


  • Deepak Verma

    Deepak Verma is a Test Automation Consultant and Software development Engineer for more than 10 years. His mission is to help you become an In-demand full stack automation tester. He is also the founder of Techndeck, a blog and online coaching platform dedicated to helping you succeed with all the automation basics to advanced testing automation tricks.