Constants and variable learning records in Java

Source: Internet
Author: User

The definition of a constant: the amount of its value does not change (more precisely, it is not changeable) during the course of the program is called a constant.

The function of constants: simple, intuitive description of a thing, is the basis of variables, is the basis of the program run.

Constants are divided into two main categories: primitive values (which do not need to be defined), such as: (1, 2.1) numeric constants, (' A ', ' Chinese ') literal constants, (true, false) logical constants, NULL constants

Class II: Immutable variable (required to be defined for use) For example: public static final int a = 1, the variable must be initialized when defined, and its value cannot be changed in the future

The definition of a variable: the amount of time that the value can change in a program when it is running is called a variable.

The role of variables: In order to store data during program run

A variable contains three parts: A variable type, a variable name, and a variable value. For example, create a variable: int a = 1, (In essence: A storage area is opened in memory, and the name and type defined for that difference can be stored in the process without changing the data of that type)

The scope of the variable: A variable can only be used in its current {}

Constants and variable learning records in Java

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.