Java Variables and constants

Source: Internet
Author: User

In program execution, the amount whose value cannot be changed is called a constant, and the amount whose value can be changed is called a variable.

One, variable

1. The variable name must be a valid identifier

2. Variable names cannot be duplicated

3. You should choose a meaningful word to make a variable name

Second, constant

Constants are also commonly referred to as "final variables", and constants can be assigned only once throughout the program and are shared for all objects.

In the Java language, declaring a constant, in addition to specifying a data type, needs to be qualified with the final keyword.

Standard syntax: Final data type constant name [= value]

Constant names are usually capitalized, which is not a rule, but most Java programmers are accustomed to using uppercase letters to denote constants, often to make it clear that constants are being used.

Cases:

Java Variables and constants

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.