Java Foundation II

Source: Internet
Author: User

Member variables: defined in a class that describes what the object will be, can be used by methods in this class, or used by methods in other classes that are related to this class

Local variables: Defined in a method, temporarily saving data in a method, only used in the current method

Define a member variable int A, the initial value is the 0,java program assigns the initial value to the member variable and does not assign an initial value to the local variable

Local variables with the same name are not allowed in the same method, and local variables of the same name can be used in different methods

Local variables are used when the local variable and member variable have the same name according to the nearest principle

The constructor method is defined in the Java class to initialize the object's method, new+ constructs the method can create the object

The constructor method has the same name as the class, has no return value, does not write a return value type, can have parameters or no parameters, and the syntax is:

Public constructor Method name () {

}

Java Foundation II

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.