Jen Baby Java Basic notes

Source: Internet
Author: User

One. Overview of methods for classes
1. What is the method of the class
The method of the class is a function module, which acts as "doing one thing"
Class method: A kind of common behavior of Things is the method of class.
2. How to define a class method
The method of a class must include the following three parts:
The name of the method
The return value type of the method
The body of the method
Public return value type method name () {
The body of the method
}
3. Method invocation
This process is called a method call in a program by using the method name to execute the statements contained in the method.
There are two forms of method invocation:
Methods in the same class, call the method directly using the method name.
Different classes of methods, first create the object, and then use the "Object name. Method Name" to invoke
4. Common errors
There is no way to define a return value type, there can be no return statement.
A method cannot have more than one return value and can have at most one
Multiple methods cannot be nested with each other, that is, methods can no longer be defined in methods.
Second, the object-oriented advantages:
1. Consistent with human thinking
2. Information hiding, improve the maintainability and security of the program
3. Improve the reusability of the program.
Object-Oriented Programming thinking:
The method of a class can implement a specific function, and other classes do not need to know how it is implemented! Knowing the class that implements this function and its method name can be called directly without repeating the encoding.

Jen Baby Java Basic notes

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.