Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
fun main(args: Array<String>) {
try{
val myVar:Int=12 val v:String="Tutorialspoint.com"
v.toInt()
}catch(e:Exception){
e.printStackTrace()
}finally{
println("Exception Handeling in Kotlin")
}
}
fun main(args: Array<String>) {
val numbers: MutableList<Int> = mutableListOf(1, 2, 3) //mutable List
val readOnlyView: List<Int> = numbers // immutable list
println("my immutable list--"+numbers) // prints "[1, 2, 3]"
numbers.add(4)
println("my immutable list after addition --"+numbers) // prints "[1, 2, 3, 4]"
println(readOnlyView)
readOnlyView.clear() // -> does not compile
// gives error
}
fun main(args: Array<String>) {
var rawString :String ="I am Raw String!"
val escapedString : String ="I am escaped String!\n"
println("Hello!"+escapedString)
println("Hey!!"+rawString)
}
fun main(args: Array<String>) {
val letter: Boolean // defining a variable
letter = true // Assinging a value to it
println("Your character value is "+"$letter")
}
fun main(args: Array<String>) {
val a: Int = 10000
val d: Double = 100.00
val f: Float = 100.00f
val l: Long = 1000000004
val s: Short = 10
val b: Byte = 1
println("Your Int Value is "+a);
println("Your Double Value is "+d);
println("Your Float Value is "+f);
println("Your Long Value is "+l);
println("Your Short Value is "+s);
println("Your Byte Value is "+b);
}