Immutable----in the change of constants for the Java language (05)

Source: Internet
Author: User

In the program, the study of variables occupies an absolute proportion, because it is changeable, can accomplish many functions, the constant is not the view of the variable as much, but the role of the constant in the program is equally important. The amount of value that does not change during program execution is constant, The concept is relative to a variable. Variables are used to store and record data such as Pi Pi constants in these mathematics.

Constants in Java are divided into two categories, one is a literal constant, and the other is a custom constant. Custom constants are well understood, such as a person's gender is immutable, and we can define it as a constant when we define it. Literal constants are written values, such as "HelloWorld" is a literal constant, called a string constant. Similar to the integer constant: such as 100,200, decimal constant: such as 12.32; character constants: such as ' A ', ' B ', etc. Boolean constants: such as True,false; An empty constant (NULL) represents an empty reference, and the reference does not point to.

Literal constants are often used to assign values to variables, or to make up a class's properties, and are simple to use, so it's easier to learn and is part of a Java program.

Immutable----in the change of constants for the Java language (05)

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.