Kotlin program to get the string equivalent of the Pair

bookmark

fun main() {
    // creating a new instance of the Pair
    val pair1 = Pair(10, 20)
    println("String representation of pair1 : "+pair1.toString())

    val pair2 = Pair("Alvin Alexander", 35)    
    println("String representation of pair2 : "+pair2.toString())
}

 


Output:

String representation of pair1 : (10, 20)
String representation of pair2 : (Alvin Alexander, 35)