 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the use of underscore keyword in Java 9?
In earlier versions of Java, the underscore ("_") has used as an identifier or to create a variable name. Since Java 9, the underscore character is a reserved keyword and can't be used as an identifier or variable name. If we use a single underscore character as an identifier, the program fails to compile and throws a compile-time error because now it is a keyword and can't be used as a variable name in Java 9 or later versions.
Example
public class UnderscoreKeywordTest {    public static void main(String args[]) {       int _ = 50       System.out.println(_);    } }  Output
UnderscoreKeywordTest.java:3: error: as of release 9, '_' is a keyword, and may not be used as an identifier int _ = 50; ^ UnderscoreKeywordTest.java:4: error: as of release 9, '_' is a keyword, and may not be used as an identifier System.out.println(_);
Advertisements
 