Java technology _java Thousands of questions (0046) _ Why underline in numeric values

Source: Internet
Author: User

Click to enter _ more _java thousand ask

1. Why underline in numeric value

This is a feature after JDK 7.
Starting with JDK 7, you can insert one or more underscores in numeric literals, including integer literals and floating-point literals. For example:

int x = 123_456_789;

When compiling, the underscore is automatically removed. However, the underscore can only be used to separate numbers, cannot delimit characters and characters, and cannot delimit characters and numbers.

The underscore can be used consecutively, for example:

float f = 1.22___33__44;

The literal value of binary or hexadecimal can also use underscores.
Remember that underscores can only be used between numbers and numbers, and are illegal for the first time. For example: 1._23 is illegal, _123, 11000_l are also illegal.

Learn about the basic data types of JAVA8:8 basic data types for Java

Java technology _java Thousands of questions (0046) _ Why underline in numeric values

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.