- 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.
推薦閱讀
- 構建移動網站與APP:HTML 5移動開發入門與實戰(跨平臺移動開發叢書)
- 控糖控脂健康餐
- Functional Programming in JavaScript
- Learning Apache Mahout Classification
- RabbitMQ Cookbook
- Swift細致入門與最佳實踐
- Java系統化項目開發教程
- Angular開發入門與實戰
- 微信小程序全棧開發技術與實戰(微課版)
- Developing SSRS Reports for Dynamics AX
- CRYENGINE Game Development Blueprints
- Orleans:構建高性能分布式Actor服務
- 從零開始:UI圖標設計與制作(第3版)
- Python網絡爬蟲技術與應用
- 30天學通C#項目案例開發