Compilation: The compilation is a process that translates the Kotlin Program Code into a form that the system can run.
Understand the parts of the program:
fun
- fun stands for function.
Note: Kotlin has many special words with very specific meanings. As you learn to program in the Kotlin language, you will learn these words. They are often called keywords or reserved words.
fun main
- main is
the name of this function. Functions have names, so they can be distinguished from each other. This function is called main because it is the first, or main, function that is called when you run the program. Every Kotlin program needs a function named main.
fun main()
- The function name is always followed by () two parentheses.
- Inside
the parentheses, you can put information for the function to use. This input to the function is called "arguments" or args for short. You will learn more about arguments later.
fun main() {}
- Notice
the pair of curly braces {} after the parentheses.
Inside a function is a code that accomplishes a task. These curly braces surround those lines of code.
Look at the line of
code between the curly braces:
println("Happy Birthday!")
This line of code
prints the Happy Birthday! text.
- println tells the system to print a line of text.
- Inside
the parentheses you put the text to be printed.
- Notice
that the text to be printed is surrounded by quotes. This tells the system
that everything inside the quotation marks should be printed exactly as
given.
0 Comments