- 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.
推薦閱讀
- Mastering Visual Studio 2017
- 前端跨界開(kāi)發(fā)指南:JavaScript工具庫(kù)原理解析與實(shí)戰(zhàn)
- Web Development with Django Cookbook
- Cassandra Design Patterns(Second Edition)
- Neo4j Essentials
- Scala謎題
- 軟件工程
- Serverless computing in Azure with .NET
- Learning Concurrency in Kotlin
- Learning Unreal Engine Android Game Development
- Java Web開(kāi)發(fā)就該這樣學(xué)
- Access 2010中文版項(xiàng)目教程
- JavaScript動(dòng)態(tài)網(wǎng)頁(yè)編程
- Kotlin極簡(jiǎn)教程
- Learning Concurrency in Python