This code also prints "hello, world!" to standard output. This time, though, the code
is wrapped in a Kotlin class, called HelloWorld
.
Then, our main()
function creates an instance of HelloWorld
via HelloWorld()
,
and we call speak()
on that instance of HelloWorld
to get our println()
call
to be executed.
You can learn more about this in:
Tags:
xxxxxxxxxx
1
class HelloWorld {
2
fun speak() {
3
println("hello, world!")
4
}
5
}
6
7
fun main() {
8
HelloWorld().speak()
9
}