Kotlin和Java的映射关系

2020-07-03 10:22:49 浏览数 (1)

基本类型

Java type

Kotlin type

byte

kotlin.Byte

short

kotlin.Short

int

kotlin.Int

long

kotlin.Long

char

kotlin.Char

float

kotlin.Float

double

kotlin.Double

boolean

kotlin.Boolean

包装类

Java type

Kotlin type

java.lang.Byte

kotlin.Byte?

java.lang.Short

kotlin.Short?

java.lang.Integer

kotlin.Int?

java.lang.Long

kotlin.Long?

java.lang.Char

kotlin.Char?

java.lang.Float

kotlin.Float?

java.lang.Double

kotlin.Double?

java.lang.Boolean

kotlin.Boolean?

对象类型

Java type

Kotlin type

java.lang.Object

kotlin.Any

java.lang.Cloneable

kotlin.Cloneable

java.lang.Comparable

kotlin.Comparable

java.lang.Enum

kotlin.Enum

java.lang.Annotation

kotlin.Annotation

java.lang.Deprecated

kotlin.Deprecated

java.lang.CharSequence

kotlin.CharSequence

java.lang.String

kotlin.String

java.lang.Number

kotlin.Number

java.lang.Throwable

kotlin.Throwable

List和Map

Java type

Kotlin read-only type

Kotlin mutable type

Loaded platform type

Iterator

Iterator

MutableIterator

(Mutable)Iterator

Iterable

Iterable

MutableIterable

(Mutable)Iterable

Collection

Collection

MutableCollection

(Mutable)Collection

Set

Set

MutableSet

(Mutable)Set

List

List

MutableList

(Mutable)List

ListIterator

ListIterator

MutableListIterator

(Mutable)ListIterator

Map<K, V>

Map<K, V>

MutableMap<K, V>

(Mutable)Map<K, V>

Map.Entry<K, V>

Map.Entry<K, V>

MutableMap.MutableEntry<K,V>

(Mutable)Map.(Mutable)Entry<K, V>

数组

Java type

Kotlin type

int[]

kotlin.IntArray

String[]

kotlin.Array<(out) String>

0 人点赞