Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Java implements method invocation

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how Java implements method invocation. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Method invocation of Java

Definition of method (method):

1 in java, programmers can use a specific task that is used many times in a program

Defined as a method. These methods are sometimes called (programmer-defined methods: programmer-defined method).

Methods can be activated (invoke) by method calls (method call) to perform other tasks. According to an example:

The boss (caller) asks the employee (the callee) to complete a task, but the boss does not know how the worker completes the task.

The organizer, such as the workshop director, receives the task and assigns it to other front-line workers. The method and its calls are like the above-mentioned relationship.

The advantage of method invocation, which enables programmers to modularize the program, has the advantage of 1. This divide-and-conquer approach makes software development

Easier to manage, 2. Another advantage is the "reusability of software", that is, using existing methods to form new programs, which is also object-oriented programming.

The key point. 3. Is to avoid the reuse of code in the program. By packaging the code as a method, you can execute the code in several different locations in the program by calling the method.

So as to speed up the execution of the program.

The method call is well illustrated with an example below.

1 / / Fig.1-1:SquareInt.java

2 import java.awt.Container

3 import javax.swing.*

4 public class SquareInt extends JApplet {

5 public void init () {

6 String output= ""

7 JTextArea outputArea=new JTextArea (100.20)

8 Container c=getContentPane ()

9 c.add (outputArea)

10 int result

11 for (int Xero1bot x

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report