Java 0 Basic Series 003--variables

Source: Internet
Author: User

Variable (variable): The most basic storage unit in the program, including the variable name, type, scope
Variables should be declared, only after the system will allocate the corresponding length of storage space, the variable is essentially the name of the storage unit
Variables are divided into local variables, member variables, constants. A local variable is typically a variable defined inside a method, and is initialized before it is declared.
A member variable is also called an instance variable or attribute, which is usually a variable defined in a class, and the method is placed at the same level, and the scope is larger than the local variable
Constant final, which is a variable that can only be initialized once, also known as the final variable

Variable naming conventions: Naming of methods and variables--lowercase letters, hump principle
Class naming-initial capitalization, hump principle
Name of the constant--all caps

 Public classVariable { Public intA//A is a member variable, here is the declaration of a     Public Static voidMain (string[] args) {intb//b is the local variable inside the main method, here is the declaration of itb = 0;//This line is initialized with 0 pairs of variable b                Final intC = 1;//C is a constant, we initialize it directly when declaring it, the value of C will always be 1, cannot be changed        }}



Java 0 Basic Series 003--variables

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.