How to print Matrix(2D Array) in Kotlin? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How to print Matrix(2D Array) in Kotlin?

I have searched alot and didn't find any way to print Matrix in Kotlin like we do in Java. I was trying to make a simple Tic Tac Toe game but and then i stucked on to make a matrix in Kotlin using 2d array.

31st Aug 2019, 4:51 AM
‎Ahmad Amin
‎Ahmad Amin - avatar
3 Answers
31st Aug 2019, 7:34 AM
Prathvi
Prathvi - avatar
+ 3
Abhishek Jain really helpful & thanks a lot for this. 😍
31st Aug 2019, 7:39 AM
‎Ahmad Amin
‎Ahmad Amin - avatar
+ 2
joinToString method is also great at dealing with matrices. It automatically places user specified strings before, during, and after the list. It can perform transformations on the data (e.g. replace zero cells as spaces.) https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/join-to-string.html
28th Sep 2019, 5:12 PM
John Wells
John Wells - avatar