|
1 | 1 | [//]: # (title: Arrays)
|
2 | 2 |
|
3 |
| -An array is a data structure that holds a fixed number of values of the same type or its subtypes. |
4 |
| -The most common type of array in Kotlin is the object-type array, represented by the [`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/) class. |
| 3 | +* := data structure / holds a fixed number of values / SAME type or its subtypes |
| 4 | + * 👁️object-type array 👁️ |
| 5 | + * most common type of array | Kotlin |
| 6 | + * -- represented by the -- [`Array`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/) class |
| 7 | + * if primitives | object-type array -> bad performance impact |
| 8 | + * Reason: 🧠 because your primitives are [boxed | objects](https://docs.oracle.com/javase/specs/jls/se22/html/jls-5.html#jls-5.1.7) 🧠 |
| 9 | + * alternative : [primitive-type arrays](#primitive-type-arrays) |
| 10 | + * Reason: 🧠 avoid boxing overhead 🧠 |
5 | 11 |
|
6 |
| -> If you use primitives in an object-type array, this has a performance impact because your primitives are [boxed](https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html) |
7 |
| -> into objects. To avoid boxing overhead, use [primitive-type arrays](#primitive-type-arrays) instead. |
8 |
| -> |
9 |
| -{type="note"} |
10 | 12 |
|
11 | 13 | ## When to use arrays
|
12 | 14 |
|
| 15 | +* TODO: |
13 | 16 | Use arrays in Kotlin when you have specialized low-level requirements that you need to meet. For example, if you have
|
14 | 17 | performance requirements beyond what is needed for regular applications, or you need to build custom data structures. If
|
15 | 18 | you don't have these sorts of restrictions, use [collections](collections-overview.md) instead.
|
@@ -379,6 +382,7 @@ fun main() {
|
379 | 382 |
|
380 | 383 | ## What's next?
|
381 | 384 |
|
382 |
| -* To learn more about why we recommend using collections for most use cases, read our [Collections overview](collections-overview.md). |
383 |
| -* Learn about other [basic types](basic-types.md). |
384 |
| -* If you are a Java developer, read our Java to Kotlin migration guide for [Collections](java-to-kotlin-collections-guide.md). |
| 385 | +* Check |
| 386 | + * [Collections overview](collections-overview.md) |
| 387 | + * other [basic types](basic-types.md) |
| 388 | + * If you are a Java developer -> read our Java -- to -- Kotlin migration guide for [Collections](java-to-kotlin-collections-guide.md) |
0 commit comments