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.
Tutorialspoint

Tool

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

Exception Handling

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") 
    } 
}

Collections

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  
}

Strings Output

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) 
     
}

Boolean Output

fun main(args: Array<String>) { 
    val letter: Boolean // defining a variable  
    letter = true    // Assinging a value to it  
    println("Your character value is "+"$letter")  
}

Characters Output

fun main(args: Array<String>) { 
    val letter: Char // defining a variable  
    letter = 'A'     // Assigning a value to it  
    println("$letter")  
}

Arrays

fun main(args: Array<String>) { 
    val numbers: IntArray = intArrayOf(1, 2, 3, 4, 5) 
     
    println("Hey!! I am array Example"+numbers[2]) 
     
}

kotlin data types

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); 
  }

myprocet

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

kjkm

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

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.