Java class differs from object _ member variable and local variable

Source: Internet
Author: User

member variables and local variables:
1. Member variables: defined in the re-class to describe what the object will be.
2. Local variables: defined in the method of the class to temporarily save the data in the method.
Difference:
1. Different scopes:
Partial: Limited to the method that defines it
Members: The entire class is visible
2. Different initial values
Local: Java does not assign an initial value to a local variable
Member: Java assigns the initial value to the member variable, 0
3 Local variables with the same name are not allowed in the same method; there can be local variables with the same name in different methods
4. When the two class variable has the same name, the local variable has a higher precedence (nearest principle)

Java class differs from object _ member variable and local variable

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.