object CombineKeysAndValues {
// Function to combine keys and values into a single string
def combineKeysAndValues(map: Map[String, String]): String = {
map.map { case (key, value) => s"$key=$value" }
.mkString(", ")
}
def main(args: Array[String]): Unit = {
val map: Map[String, String] = Map(
"Key1" -> "Value1",
"Key2" -> "Value2",
"Key3" -> "Value3",
"Key4" -> "Value4"
)
val result = combineKeysAndValues(map)
println(s"Combined keys and values: $result")
}
}
/*
run:
Combined keys and values: Key1=Value1, Key2=Value2, Key3=Value3, Key4=Value4
*/