ADVERTISEMENT
ADVERTISEMENT

Kotlin program to get the string equivalent of the Triple

Example of toString() function: Learn how to get the string equivalent of the Triple?
Submitted by IncludeHelp, on April 09, 2022

Here, we will demonstrate the use of the toString() function with Triple in Kotlin. The toString() function returns the string equivalent of the Triple.

Syntax:

fun toString(): String

Example 1:

fun main() {
	// creating a new instance of the Triple
	var numbers = Triple(10, 20, 30)

	// Printing the Triple in string format
	println("String representation is "+numbers.toString())	
}

Output:

String representation is (10, 20, 30)

Example 2:

fun main() {
	// creating a new instance of the Triple
	var student = Triple("Alvin Alexander", 35, "New York")

	// Printing Triple in string format
	println("String representation is "+student.toString())	
}

Output:

String representation is (Alvin Alexander, 35, New York)

Kotlin Triple Programs »


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.