# Arrays

`var students = [3]string`
`var numbers = [3]int{27, 42, 11}`
`var animals = [...]string{"Lion", "Gorilla", "Cat", "Dog"}`
`students := [...]string{"Sean", "Elaina", "Clark"}fmt.Println(len(students)) //method used to print to console//returns 3 as we have 3 elements in the array`

# Nested Arrays

`var twoDimendionalArray[3][3]int = [3][3]int{[3]int{1, 1, 0}, [3]int{0, 1, 1}, [3]int{0, 0, 1}}`
`/*We initializing our array to contain 3 elements within the array and the arrays within that array are going to also contain 3 elements.arrays are 0 indexed, meaning that they start from zero instead of starting at 1.we are then assigning first element of the array to contain an array with 1, 1, 0 and following the same process with the second and third element in the array*/var twoDimendionalArray[3][3]inttwoDimendionalArray[0] = [3]int{1, 1, 0}twoDimendionalArray[1] = [3]int{0, 1, 1}twoDimendionalArray[2] = [3]int{0, 0, 1}`
`[ [1,1,0] [0,1,1] [0,0,1]]`

# Array Pointer

`array1 := int[3]{33,63,74}array2 := firstArray`
`array1 := int[3]{33,63,74}array2 := &array1array2[0] = 69fmt.Println(array1)fmt.Println(array2)//Output:/*  [69,63,74] [69,63,74]It changes both of the arrays because array2 is not pointing to array1 instead of just making a copy of array1*/`

# Resources

--

--

--

## More from Sean Dever

Love podcasts or audiobooks? Learn on the go with our new app.