Javatpoint Logo
Javatpoint Logo

Java Numeric Literals with Underscore

Java allows you to use underscore in numeric literals. This feature was introduced in Java 7. This feature enables you, for example, to separate groups of digits in numeric literals, which can improve the readability of your source code.

The following points are considerable:

  • You cannot use underscore at the beginning or end of a number.
  • You cannot use underscore adjacent to a decimal point in a floating point literal.
  • You cannot use underscore prior to an F or L suffix
  • You cannot use underscore in positions where a string of digits is expected.

Underscores in Numeric Literals Example


a = 1000000
b = 10.5
c = 10
d = 17
e = 9

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA