Variables and constants

Source: Internet
Author: User

Statement: The material used in this column is written by the VIP students of the Kay Academy, who has the right to be anonymous and has the final right to interpret the article; The Edith Academy is designed to promote students to learn from each other on the basis of public notes.

A. Variable

1. The data stored inside can be modified by the logo;
2. Application format: data type name;

Remember that an assignment is an overlay, which overrides the value in it, such as:
Assignment is overwrite = is to overwrite the old value int age=100;
The age end value is age=100 int;
System.out.println (age);
System.out.println (age);
System.out.println (age);
System.out.println (age); 3. Enter a name requirement: The preceding letter is lowercase;
4. Request a storage space for a data type to memory, and then allocate contiguous byte memory for the corresponding byte of the data type.

Two Constant
1. The first time you can set the identifier to point to a data, late can not be modified;
2. Application format: final data type name;
such as: Final int age=100; age=10; The error can not give the constant to the second value final float FF;
final int age=100;
Final float FF;
Final byte a,b,c,d,e,f;

3. Constant in the application can not give value, can be used before the value, but remember can only be given once;
4. Enter the name requirement: All capitals must be capitalized;
5. The constant name usually points to a memory address,

Three Note: 1. Either the variable or the constant is just an identifying symbol, which points to a memory address;

2. No matter what the name is, the letter or underscore begins, you can use the end of the number;
3. Within the same region (within a curly brace) the same name cannot be applied;
4. There are also types of values: Some values are not compatible after they are assigned to the data type, and the assignment formats are different;
① integer int;
② decimal Double;
③ ' char;
④ "" String;
⑤true|false Boolean;
⑥float cannot accept decimals because decimals are double types, large data types are not decimal types
⑦long cannot accept the number of long integers in its own range, because all ints are of type int and the int type is up to 2.1 billion;

5. Common data type: Byte int double Boolean.

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: 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.