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
Monday, 18 December 2017
New
Kotlin Hello world,variable and arrays
About Wise4rmGod
android developer and a graphic designer,who likes to blog and share latest IT information and help young developers grow.
tutorials
Labels:
tutorials
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment