Beruflich Dokumente
Kultur Dokumente
Introduction to procedures
A procedure is a set of one or more program statements ,
which can be executed by referring to the method name.
Procedures are useful for performing repetitive tasks.
They allow you to break an application into discrete logical
units, which make the application more readable.
Dividing a complex application into methods makes code
more flexible and easy to maintain and to debug.
Introduction to procedures
To use procedures, you need to define them.
(contd..)
Introduction to procedures
The elements of the method declaration include the method
(contd..)
name, the parameters list, the return type, and the method
body.
The following are the elements of a method:
Access specifier
Return type
Method name
Parameter list
Method body
Introduction to procedures
Defining a method means declaring
(contd..)
This determines the
the elements of its structure.
Consider the syntax of defining a
method:
<Access specifier> <Return Type>
<Method Name>(Parameter List)
{
Method Body
}
extent to which a
variable or method
can be accessed
from another class.
Introduction to procedures
Defining a method means declaring
(contd..)
A method can return
the elements of its structure.
Consider the syntax of defining a
method:
<Access specifier> <Return Type>
<Method Name>(Parameter List)
{
Method Body
}
Introduction to procedures
Defining a method means declaring
(contd..)
This is a unique
the elements of its structure.
Consider the syntax of defining a
method:
<Access specifier> <Return Type>
<Method Name>(Parameter List)
{
Method Body
}
identifier and is
case-sensitive.
The method name
cannot be the
same as the
variable name or
any other
non-method item
declared in the
class.
Introduction to procedures
Defining a method means declaring
(contd..)
the elements of its structure.
Consider the syntax of defining a
method:
<Access specifier> <Return Type>
<Method Name>(Parameter List)
{
Method Body
}
Introduction to procedures
Defining a method means declaring
(contd..)
This contains the
the elements of its structure.
Consider the syntax of defining a
method:
<Access specifier> <Return Type>
<Method Name>(Parameter List)
{
Method Body
}
set of instructions
needed to complete
the required activity.
Unary Operators
Introduction to procedures
After defining the method, you can execute it by calling it.
(contd..)
You can call a method by using the name of the method.
The method name is followed by parentheses even if the
method call has no parameters, as shown in the following
example:
MethodName();
Comparison Operators
Introduction to procedures
Consider the following code snippet of method definition :
(contd..)
public int AddNumber(int num1, int num2)
{
int result;
result = num1 + num2;
return result;
}
Logical Operators
Summary (Contd.)
Summary
Introduction to procedures
Declaring the procedures
Invoking procedures
Argument passing mechanism