Look for the main because the program starts there. The keyword fun here means function. The main here is just the name of the method but since it is the start of the program, this is required. The parenthesis () signify that this is a method. The opening brace is the start of the body of the method and it ends in a closing brace. The print is just one of the method whose function is to print something in the console but if it is a println, it functions the same way but have an added function which is making sure that the next string would be printed on the next line. So, print or println does accept one parameter which is a string. This time it is "Hello Wattpad". And it doesn't end in a semi colon just like in java. The compiler can tell or infer if it is the end of the code only if it sees the next line. So, make sure that your next code is in the next line.
===============
fun main(){
print("Hello Wattpad")
}
==============
Result:
Hello Wattpad
If you want to add some arguments in the main, this is allowed too.
==============
fun main(args: Array<String>){
println(args.contentToString())
}
==============
Result:
[Testing1]
Note: Make sure that before running the program, you edit the configuration for running the program by adding some arguments like this word Testing1 to the program arguments area.
DU LIEST GERADE
Kotlin Programming
SonstigesI have been trying to learn things online. I will put my notes in here. I put things in my own words and i do not copy their programs. I try to do things the right way so that i may learn. Below is the site where i study. Go check this out if you wa...
