Why use ! after name in kotlin language?


#1

fun main(args: Array) {
for (name in args)
println(“Hello, $name!”)
}


#2

I am not sure what you mean. You can write

fun main(args: Array<String>) {
    for (name in args) {
        println("Hello, $name")
    }
}

The ! is just part of the sentence. You could just as well put a . there or any other special character. If you want to add any normal character(“a-z”, “A-Z”, “0-9”, etc) right after the content of the string you can use

prinntln("foo ${someVar}lolo")