Look Back, Java restudying (v): Variables of the Java Foundation

Source: Internet
Author: User
Tags modifier

    1. Variables in all programming languages, belong to the most basic part, learning this part of the basic language, variables can be divided into member variables and local variables
    2. The declaration format of variables in Java is as follows, if the modifier is not added, the default is defaults, about the modifier, we will refer to here, only to understand, the type must be added, and each variable must correspond to a type, the variable name is usually beginning with a letter, a sequence of letters or numbers, However, in Java, the scope is larger, the letters include a~za~z_$, but the use of special characters is not recommended, variable name length is not limited, and case-sensitive.

Format: [Modifier (Public private static final, etc)] type (base type and other type) variable name;

For example: int count, or private int count;

3. Variables must be initialized before use, otherwise the compiler will error (variable not initialized), so-called initialization is assigned, such as int count = 0;

4. A constant is a special variable, using the final decoration, can only be assigned once, the assignment will not be changed, it is customary to capitalize the constant name and use the static decoration as a class constant, the specific scope of use needs to be based on the modifier, if restricted to private can only be used in this class, The specific usage is as follows:

In this class the call is directly using the constant name, for example: int i = 1 + final_int;

Called in other classes uses the type. Constant name, for example: int i = 1 + test.final_int;

5. Finally, I would like to collect a brief description of the variable memory allocation, in the collection process found a lot of good blog, so do not intend to write from scratch, because Java memory management belongs to the core technology, not suitable for beginners to drill, so if there is no Java programming Foundation, suggest just look at the next, A blog about Java memory Management is attached below: http://blog.csdn.net/rj042/article/details/6871030

  

  

Look Back, Java restudying (v): Variables of the Java Foundation

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.