Simple Methods

The simple methods are tasked to do a certain task, which helps to solve a given problem. These actions can be printing a string on the console, doing a verification, executing a loop and others.

Let's see the following example for a simple code:

This method must print a header, which is a sequence of hte - symbol. Because of this its name is PrintHeader. The parentheses ( and ) always follow the name, no matter what we called the method. We will later see how to name the methods we work with and for the moment we will only say that it is important for its name to describe the task the method is doing.

The body of the method contains the program code, which is between the curly brackets { and }. These brackets always follow its declaration and between them we write the code, which solves the problem described by the methods name.

results matching ""

    No results matching ""