📜  void 与非 void 方法 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:25.303000             🧑  作者: Mango

代码示例1
-void : does not return any value. The "void"
return type means that this method doesn't
have a return type.
    In an application, this approach may be used 
    to print runtime specific messages on the console. 
    Exp: "setter" in encapsulation.
    
    -non-void: MUST return a Value.
    (Data type needs to be same with return-type)
    This means that you can use the returned 
    value in your code for further processing.
    I guess good examples of such methods are "getter" in encapsulation.