Methods
In this lesson, you will get to know the role of methods in classes.
We'll cover the following...
We'll cover the following...
The Purpose of Methods
In general, methods act as an interface between a program and the fields of a class in that program.
These methods can either alter the data stored in the fields or use their existing values to perform a certain computation. All the useful methods should be public
, although, some methods which do not need to be accessed from the outside could be kept private.
Definition and Implementation
A method is a group of statements that performs some operations and may or may not return a ...