This is a creation in Article, where the information may have evolved or changed.
Arrays Array
- Define the format of the array: var [n] , n >= 0
- Array lengths are also part of a type, so arrays with different lengths are of different types
- Note A pointer and pointer array that points to an array
- Array is a value type in Go
- You can use = = or! = to compare between arrays, but you cannot use < or >
- You can use new to create an array, and this method returns a pointer to the array
- Go supports multidimensional arrays
12345678910111213141516171819202122232425 |
//multidimensional array definition func main () {numbers: = [2][3]int{{1,2,3},{4,5,6}}}//Bubbling func main() {numbers: = [Ten]int{1,6, -, at, the,133,222,333,2,111} forI: =0; I <Len(numbers); i++ { forJ: = i +1; J <Len(numbers); J + + {ifNumbers[i] > Numbers[j] {tmp: = numbers[j]numbers[j] = numbers[i]numbers[i] = tmp}}}fmt. PRINTLN (Numbers)} |