Java SE Foundation Consolidation

Source: Internet
Author: User
Tags java se

1. When the parameter and the member name are used in conjunction with the This keyword, this is a reference to the object to which the method belongs;

2. Construct the code block:

Features: The object is run as soon as it is established and takes precedence over the execution of the construction method

Function: Used to initialize an object

And the difference of the construction method: The construction method is to initialize the corresponding object, construct the code block is the initialization content that defines the commonness of different objects

3. Call between constructs method: can only be done by the this statement, and can only be written in the first row, a construction method can only import a constructor method

4.static modifiers (also known as static variables, static members, class variables): Used to decorate member variables and member methods, in-memory data segment, or shared areas. The instance object is a variable that is not static and is stored in the object.

Features: Only one copy of the modified member variable;

When the member is modified by static, there is one more access way, that is, the class name is called directly;

Loaded with the name of the class, takes precedence over the object and is shared by all objects

5. Static method Considerations: 1. Static methods can only access static members;

2. Static members can be accessed by non-static methods;

3. Local variables cannot be modified by static

4. The This,super keyword is not defined in a static method because static overrides the existence of the object

When do I use static methods? When a non-static member is not accessed internally, the function can be defined as a static

6. Life cycle: The class variable life cycle is the longest and disappears as the class disappears

The instance variable has the shortest life cycle and disappears as the object disappears

7. Main function

1.public represents the maximum access permission for the class or the function

2.static represents the main function as the class is loaded, it already exists.

3.void represents no specific return value

4.main is not a Java keyword, he is a special word, variable is not a keyword, can be recognized by the JVM

5.string[] The parameter type of the args function is an array of string types, and when the array is empty, there is no minus mark

8. Static Application Tool class

Each application has common features that can be extracted, encapsulated, and reused

9. Object: Used to encapsulate data, as long as there are non-static members in the class, the object must exist

10.classpath: Mainly used at execution time: Set classpath= ...

Set classpath=. (single. Represents the current directory)

Set classpath=.; ... (Of ... Two directories are available)

11. Document annotation related, document extraction tool Javadoc.exe javadoc-d Mydoc (no Mydoc will be created automatically)-author-version ***.java guaranteed class is public

/**

@param represents the incoming

@return means return

@author indicates that the author

@version represents a version

*/

12. Static code blocks (different from building blocks of code)

Execution statements in static statically-coded code

Feature: Executes as the class is loaded and executes only once, and takes precedence over the main function

Function: Used to initialize a class

13.new memory operation steps for an object

1.new ... Will load the class from the hard disk into memory;

2. If static blocks of code are loaded with the load of the class, the same is true for static members and common methods

3. Open up space in heap memory, allocate memory address;

4. Create a unique attribute in the heap and initialize the unique attribute at the same time by default

5. Display initialization for a property

6. Execute the Construction code block to initialize all objects

7. Execute the constructor to initialize the object

8. Give the memory address to the variable in the stack

Java SE Foundation Consolidation

Related Article

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.