Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Why use Underscore in Numbers from Java? Underscore in Numeric Literals Example

Why Use Underscore In Numbers From Java? Underscore In Numeric Literals Example
JDK 1.7 release had introduced several useful features, despite most of them being syntactic sugar, there use can greatly improve readability and code quality. One such feature is the introduction of underscores in numeric literals. From Java 7 onwards you can write a long digit e.g. 10000000000 to a more readable 10_000_000_000 in your Java source code. One of the most important reasons for using an underscore in numeric literal is avoiding subtle mistakes that are hard to figure out by looking at code. It's hard to notice a missing zero or extra zero between 10000000000 and 1000000000, than 10_000_000_000 and 1_000_000_000.


This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here

Share the post

Why use Underscore in Numbers from Java? Underscore in Numeric Literals Example

×

Subscribe to Javarevisited: Blog About Java Programmin

Get updates delivered right to your inbox!

Thank you for your subscription

×