Mastering Java: Methods/Functions (Using BlueJ)

Опубликовано: 13 Апрель 2026
на канале: KIPS Learner's Channel
1,069
19

Mastering Java: Methods/Functions (Using BlueJ)

A program is a set of instructions given to a computer. These instructions perform some specific tasks and can also
compute results. When a program becomes lengthy, it becomes difficult to organize and read. To overcome this
problem, professional programmers break down the programs into small modules (or executable instructions) called
Functions/Methods.
Definition: A function is a block containing a number of statements, which performs a specific and well-defined
task(s). Every function has a unique name which is used to identify it in a program. Once a task is packaged in a
method, it can be called from anywhere in a program through other statements.
In this manner, we can also avoid the practice of repetition of code in a program. For example, in a program, we have to
perform a particular task many times. Rather than writing the statements again and again, we can write them once
within a function and the same function can be called as many times as we want.
These modules (methods) also make the program easy to read, edit and understand. Generally, the statements in a
program are executed on the basis of their written sequence. By using methods, we can change the sequence of the
execution of statements as per our requirement.