Method Review ~ JavaSE

The conceptual approach

Methods: The talk is a function extracted, which is defined in the code alone form a separate function
when we need this feature, you can go to call, to achieve the reusability of code, but also solve the problem of redundant code

Defined methods

The general format definition:

修饰符s 返回值类型 方法名(参数列表) {
    代码。。。方法体
    return 
}

Modifiers: Some attribute modification methods (detailed in part to write object-oriented)
method name: We can call the method by method name
if the return value type clear, you need to return the value of a particular type
if the return value type is void, then the return may be omitted, with the return statement may direct method ends

Method call

Overloaded methods

Guess you like

Origin www.cnblogs.com/wbyixx/p/11846464.html