GO language program with an example of Hash Table
Maps are un-ordered collections, and there's no way to predict the order in which the key/value pairs will be returned. Every time when you run the program, every iteration over a map could return a different order.
Example
// GO language program with an example of Hash Table
package main
import (
"fmt"
)
func main() {
var country map[int]string
country = make(map[int] string)
country[1]="India"
country[2]="China"
country[3]="Pakistan"
country[4]="Germany"
country[5]="Australia"
country[6]="Indonesia"
for i, j := range country {
fmt.Printf("Key: %d Value: %s\n", i, j)
}
}
Most Helpful This Week
How to convert String to Boolean Data Type Conversion in Go?
5 Must-Know Blockchain Trends for 2024 and Beyond
Golang read json file into struct
How to declare Interface Type in Go Programming Language
Golang program for implementation of Binary Search
How do you send an HTTP POST request with an HTTP client in Go?
How do you handle HTTP errors in Go?
How do you send an HTTP PUT request in Go?
Cannot use <variable> as <type> value in return statement error in Golang
Creating a Struct Instance Using a Struct Literal