Kotlin Hello world,variable and arrays - Joklinz-Tech

Latest

Home Of Tech news,jobs and android tutorials

Monday, 18 December 2017

Kotlin Hello world,variable and arrays

Kotlin is a statically-typed programming language that runs on the Java virtual machine
and today we are going to do some practice on variable,array and write a simple program "Hello world"

firstly we need to know what function or method prints out values in kotlin

fun main(args: Array<String>) {
    println("Hello, world!")

}

fun main: is the main function where the program execution starts

print():is the function that outputs your values

while printl():prints it in a new line

Note:semicolon is optional ";"

variable
variable is a temporary memory location that holds value


fun main(args: Array<String>) {
val john="i am happy"
    println(john)

}
it will print "i am happy"

Array
 Array represents a collection of elements values or variables

fun main(args: Array<String>) {
    val array=arrayOf("john","wisdom")
  
    println(array[0])
}
it will print "John" because john is the first index in the array

for testing your kotlin skills online for free just goto the link below
link

No comments:

Post a Comment