Java Basics Summary-Methods (functions)

Source: Internet
Author: User

The role of---function---
Code to implement a specific function--a way to reuse code
The format of the---function---
The access modifier returns a value type function name (parameter list) {statement;}
Parameter list contains the parameter's type and parameter name (parameter list to note order)
---details about the function---
1. Methods are only invoked to be executed, methods can only be called in methods, methods cannot be defined
2. The level of the function is a sibling
3. The entrance to the program is the main function
4. The return value of the function is given to the caller for processing by the caller
5. The return value of the function is independent of the parameter type
6.return+ return value type, or no return value return;--function call ends
7. The stack space is freed after the function call ends
---How to define the function according to the requirements of two explicit----
1. Result of function---return value type
2. Whether unknown content is required to participate in the implementation of the function---is the parameter list
---compiler and JVM's respective responsibilities---
Compiler---does not check for content other than syntax
JVM---Start running programs, allocate appropriate memory, etc.
---function overloading---
Allows a function of the same name to exist with a different argument list in the same class, distinguishing different functions from the argument list.
Advantages: Easy to read and optimize program design
---The learning---about functions
The practice is the requirement analysis, must carry on the necessary practice

Java Basics Summary-Methods (functions)

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.