Java 7 - Underscores in Numeric Literals

In this tutorial we will discuss about Underscore in Numberic feature added in Java 7. This is a nice and small feature which has added in Java 7 gives good readability for our codes. Its nothing but we can use underscores ( _ ) in-between numberic values in our code. Underscore can be added anywhere in the value part with few constraints listed below,ALLOWED:In-between 2 numbers or hexadecimal values or binary values are allowed. Below are the few valied literals by using underscore which are given in Oracle docs.

Can't place underscore at beginning or end of the numberic value.Adjacent to a decimal point in a floating point value literal is not allowed Prior to an F or L suffix are not allowed Positions where a string of digits is expected are not allowed