function (method) declaration and invocation in Java

Source: Internet
Author: User

Currently, we have learned about functions that have no return value and have no parameters.

Next is the function call, the function that needs the parameter should pass in the parameter when calling, the parameter type and quantity should be the same as the declaration.

The return value is primarily the return of a data after the function has finished executing.

Its main function is to separate the code of different functions into multiple parts, which is convenient for reusing the code.

Basic concepts of functions (methods)
(How to use, when to use)
public static void Main (String [] args) {}

Functions without parameters with return values
public static void XxxXxx1 () {

}
function with parameter without return value
public static void xxxXxx2 (int A, String s) {

}
function with parameter with return value
public static int xxxXxx3 (int A, String s) {
return 1;
}


public static String Draw (int x1,int y1, int x2, int y2) {
System.out.println ("line drawing ....");
Return "";
}

function (method) declaration and invocation in Java

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.