Java Variable Learning notes

Source: Internet
Author: User

int i = 100;

System.out.println (i);

i = 200;

System.out.println (i);

int i = 300;

Perform an error because the same variable name cannot be named within the same scope

About the scope of variables in Java

What is a scope?

In other words, the valid range of variables, in addition to the scope of access is not, such as the company's internal property of the company can not be used, scope has size range only said

The scope of a variable just remember a word, except the curly braces don't know

public static void Main (string[] args) {

int 1 = 100;

}

public void Read () {

System.out.println (i);

}

Classification of variables

Classification based on the position of the variables appearing in the station

Variables declared within a local variable method

Variable of member variable method in vitro declaration

Java Variable Learning notes

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.