Friday, August 11, 2017

Methods


A method is a collection of statements that are grouped together to perform an operation.

Method describes the behavior of an object

Creating Method

Syntax

modifier returnType nameOfMethod (Parameter List) {

// method body

}



Parameter Vs. Argument



Parameter is variable defined by a method that receives value when the method is called.

Parameter are always local to the method they dont have scope outside the method.

argument is a value that is passed to a method when it is called.



Example

No comments:

Post a Comment