Java basics-1. Basic syntax, java-1 basic syntax

Source: Internet
Author: User

Java basics-1. Basic syntax, java-1 basic syntax
1 variable assignment and method call 1.1 assign values to private member variables

Source: private variables cannot be directly modified. Extended Methods

 

 

1.2 call Methods

 

1.3 Supplement 1: transition object-Interface

 

 

2. Call Sequence

Class loading, object creation, method calling

Static à object (constructor à general method) à local variable

 

3. code block, 3.1 Priority

 

 

3.2 three types of code blocks

 

3.2.1 construct a code block

Construct a code block: Initialize all objects in a unified manner.

2: Role

1: Initialize the object. The object runs as soon as it is created and takes precedence over the constructor.

2: differences from Constructors

1: The difference between the Construction Code block and the construction function. The construction code block initializes all objects in a unified manner, and the construction function initializes the corresponding objects.

2: Construct a code block: It extracts public information from all constructor methods.

 

 

3.2.2 static code block
1. The static code block cannot exist in any method.
2 static code blocks cannot directly access static instance variables and static instance methods. They must be accessed through instance objects of the class.

 

 

 

 

 

 

 

 

 

View comments

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.