"Go Learning note" 6, array

Source: Internet
Author: User
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)}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.