Home

Kotlin Class

Kotlin Class class Person { /…/ } class Empty Constructors // primary constructor, only one class Person constructor(firstName: String) { /*...*/ } 如果主构造函数没有什么注解和可见性修饰, 那么constructor可以忽略 主构造函数没有代码块, 可以写在init块中, init块可以有多个, 与在代码中的顺序一致, 与属性定义交错在一起 主构造函数定义的参数可以当属性使用, 可以有默认值 class Person(val pets: MutableList<Pet> = mutableListO...

Read more

Kotlin Control Flow

Kotlin Control Flow if 是表达式, 可以返回值 val max = if (a > b) a else b val max = if (a > b) { print("Choose a") a } else { print("Choose b") b } when 是表达式, 可以返回值. 顺序匹配直到匹配值, 都不满足就用else分支 下面条件else分支是必须的 when has a subject of an Boolean, enum, or sealed type, or their nullable counterparts. branches of when don’t...

Read more

Android KTX

Android KTX Reference 在 Android 开发中使用常见的 Kotlin 模式 Jetpack Compose Kotlin 样式指南 Android KTX

Read more

Android 协程

Android 协程 在Android使用协程 dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9") } Reference Android 上的 Kotlin 协程 Coroutines guide

Read more

Java Generics

Java Generics 约定使用单字符当类型参数的名称: E — Element (used extensively by the Java Collections Framework) K — Key N — Number T — Type V — Value S,U,V etc. — 2nd, 3rd, 4th types T (Type) 具体的Java类 E (Element)在集合中使用,因为集合中存放的是元素 K V (key value) 分别代表java键值中的Key Value N (Number)数值类型 ? 表示不确定的 Java 类型 为什么使用泛型 Stronger type checks at compile time. Ena...

Read more

Java GC

Java GC Java Memory Model ![jvm-architecture]((https://github.com/LiMingFei56/picturebed/raw/main/jvm/jvm-architecture.png) JVM参数: -XmsSetting — initial Heap size -XmxSetting — maximum Heap size -XX:NewSizeSetting — new generation heap size -XX:MaxNewSizeSetting — maximum New generation heap size -XX:MaxPermGenSetting — maximum siz...

Read more