In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "how Go accesses array elements". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "Go how to access array elements" can help you solve your doubts.
Access array elements
Array elements can be read by index (position). The format is the array name followed by parentheses, and the value of the index is in the brackets. For example:
Var salary float32 = balance [9]
The above example reads the value of the 10th element of the array balance.
The following shows an example of a complete operation of an array (declaration, assignment, access):
Example 1
Package main
Import "fmt"
Func main () {
Var n [10] int / * n is an array of length 10 * /
Var i,j int
/ * initialize elements for array n * /
For I = 0; I < 10; iTunes + {
N [I] = I + 100 / * set the element to I + 100 * /
}
/ * output the value of each array element * /
For j = 0; j < 10; jacks + {
Fmt.Printf ("Element [% d] =% d\ n", j, n [j])
}
}
The execution result of the above example is as follows:
Element [0] = 100Element [1] = 101Element [2] = 102Element [3] = 103Element [4] = 104Element [5] = 105Element [6] = 106Element [7] = 107Element [8] = 108Element [9] = 109. at this point, the article "how to access array elements by Go" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it. If you want to know more about related articles, Welcome to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.