Home > Java > Javagetting Started > what is method in java

what is method in java

王林
Release: 2020-06-19 09:48:13
Original
4070 people have browsed it

what is method in java

Definition of method:

A method is a collection of code blocks designed to achieve a specific function.

The grammatical functions of the method mainly include the following two:

1. Structured code

Organize the code according to functions so that the structure of the code can be compared Clear, easy to read and modify, which means the program is highly maintainable.

2. Reduce code duplication

A fixed function may be used multiple times in the program. When using it, you only need to call the written method instead of repeatedly writing the corresponding function code. .

(Video tutorial recommendation: java video tutorial)

You need to pay attention to the following two points when writing the method:

1. Rigorous logic

method implements a complete function, so when writing, you must consider various possible situations and handle each situation appropriately.

2. Strong versatility (reusable)

The method implements a function. In actual implementation, the method can be made to have a certain degree of versatility as needed, unless necessary. Otherwise don't write dedicated methods.

In the Java language, proper usage will make the program more elegant and easier to read and use.

Recommended tutorial: java entry program

The above is the detailed content of what is method in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template