- Kotlin for Enterprise Applications using Java EE
- Raghavendra Rao K
- 118字
- 2021-06-10 18:49:24
Arrays in Kotlin are invariant
Arrays in Kotlin are not built on native types, but are instead based on a Java array. Although these are similar, they do behave slightly differently. In Java, we can assign an array of a type to an array of its parent type. Arrays in Kotlin are invariant, which means that an array of a specific type cannot be assigned to an array of its parent type. It is not possible to assign Array<Integer> to Array<Any>. This provides implicit type safety and prevents possible runtime errors in the application. Kotlin also provides specialized classes to create arrays of primitive data types, including ByteArray, ShortArray, and IntArray.
推薦閱讀
- 多媒體CAI課件設計與制作導論(第二版)
- Mastering Selenium WebDriver
- C語言程序設計
- Quarkus實踐指南:構建新一代的Kubernetes原生Java微服務
- C#程序設計
- Modular Programming in Java 9
- Express Web Application Development
- Unity 2017 Mobile Game Development
- Tableau 10 Bootcamp
- Learning jQuery(Fourth Edition)
- Mastering PowerCLI
- Python數據預處理技術與實踐
- Developing Java Applications with Spring and Spring Boot
- Mastering JavaScript Promises
- JavaScript程序設計基礎教程(慕課版)