2
【笔记】Go语言的数组
source link: https://loli.fj.cn/2023/01/19/Go%E8%AF%AD%E8%A8%80%E7%9A%84%E6%95%B0%E7%BB%84/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
【笔记】Go语言的数组
2023-01-19Go语言学习指北
Go语言的数组学习笔记
var 数组名 [数组长度]数据类型
var 数组名 [数组长度]数据类型 = [数组长度]数据类型 {数据, 数据, ...}
数组名 := [数组长度]数据类型 {数据, 数据, ...}
数组名 := [...]数据类型 {数据, 数据, ...}
获取元素值
- 下表从0开始
数组名[下标]
修改元素值
数组名[下标] = 元素值
fmt.Println(数组名)
for i := 0; i < len(数组); i++ {
fmt.Println("数组下标: ", i)
fmt.Println("数组下标: ", 数组名[i])
}
for i, v := range 数组名 {
fmt.Println("数组下标: ", i)
fmt.Println("数组下标: ", v)
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK