Answers for "how to declare an array of objects in golang"

Go
0

how to declare array in golang

package main
import "fmt"

func main() {
	var x [5]int // An array of 5 integers

	x[0] = 100
	x[1] = 101
	x[3] = 103
	x[4] = 105

	fmt.Printf("x[0] = %d, x[1] = %d, x[2] = %dn", x[0], x[1], x[2])
	fmt.Println("x = ", x)
}
Posted by: Guest on February-26-2021

Code answers related to "how to declare an array of objects in golang"

Browse Popular Code Answers by Language