What Is a "Method"?

Up until now we found out that when writing the code of a program, which solves a problem, what makes it easier is that we divide the task into parts. Each part fulfills a given action and this way it is not only easier to solve the task, but the readability of the code and looking for mistakes is significantly better.

Each piece of code, which executes some functionality and has been separated logically can take the functionallity of the method. This is exactly what methods are – pieces of code with names given by us in a certain way and which can be invoked as many times as we need them.

A method can be invoked as many times, as we think we need to solve a problem. This saves us repeating the same code over and over, and also reduces the possibility to miss a mistake when correcting the code.

results matching ""

    No results matching ""