You can
print key, values from a map using for loop.
Example
for key,
value := range employees {
fmt.Println(key, " : ",
value)
}
App.java
package main import "fmt" func main() { employees := map[int]string{ 1: "Krishna", 2: "Ram", 3: "Chamu", //Must have trailing comma } for key, value := range employees { fmt.Println(key, " : ", value) } }
Output
1 :
Krishna
2 : Ram
3 :
Chamu
No comments:
Post a Comment