Home  >  Article  >  Java  >  What is the return value in Java

What is the return value in Java

little bottle
little bottleOriginal
2019-05-30 17:45:2014935browse

What is the return value in Java

In the case of ordinary classes or when you define a java method, you must define a return value type or use a void placeholder.

Then return a return value at the end of the method body, which needs to be consistent with the return value type when defined. Then when this method is called, the return value will be transferred to the calling location.

To put it simply, the return value is to return a signal or result to you after doing something.

/**
 *    方法
 */
public static String add(){//String返回值类型的方法
    String num;//定义一个String局部变量
    return num;//返回局部变量
}
 
/**
 *    主函数
 */
public static void main(String[] args){
    add();//调用add方法
}

The above is the detailed content of What is the return value in Java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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