Intern
Mis on massiiv (array)?
sobes.tech AI
Vastus AI-lt
An array is an ordered collection of elements of the same type with a fixed size.
// declare an array of 5 integers
var a [5]int
// assign values to elements
a[0] = 10
a[4] = 50
// access elements
x := a[0] // x = 10
Main features:
- Fixed size: The size of the array is determined at the time of declaration and cannot be changed during execution.
- Elements of the same type: All elements in the array must have the same data type.
- Sequential storage: The array elements are stored sequentially in memory, allowing fast access by index.
- Indexing: Access to elements is done via a numeric index, starting from 0.