In this section, you will learn about how you can use underscore in Numeric Literals in Java SE 7.
In Java SE 7, You can place any number of underscore( _ ) between digits of numeric literals. This added feature improves the readability of the code. For example : Using underscore you can separate groups of digits in numeric literals . For Example credit card number can be write as follows :
long creditCardNumber = 1234_5678_9012_3456L;
You can place underscore between digits. But for placing underscore you need to be careful. You can't place underscore in the following places :
Some of the valid example with different type of data type is given below :
Some of the invalid examples are given below :
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.