Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Create your online store today with Shopify

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Disclosure: My content contains affiliate links.

43,086 questions

55,959 answers

573 users

How to create a map with key type point (x, y) and value type string in Kotlin

1 Answer

0 votes
fun main() {
    // Define Point as a data class
    data class Point(val x: Int, val y: Int)

    // Create a map with Point keys and String values
    val pointMap = mapOf(
        Point(2, 7) to "A",
        Point(3, 6) to "B",
        Point(0, 0) to "C"
    )

    // Print x and y separately
    for ((point, value) in pointMap) {
        println("x: ${point.x}, y: ${point.y} => $value")
    }
}


 
  
/*
run:

x: 2, y: 7 => A
x: 3, y: 6 => B
x: 0, y: 0 => C

*/

 



answered Aug 10, 2025 by avibootz

Related questions

3 answers 251 views
2 answers 144 views
1 answer 154 views
1 answer 159 views
3 answers 175 views
...