<div class="sample" markdown="1" data-min-compiler-version="1.1"> 代码语言:javascript 代码运行次数:0 运行 AI代码解释 //sampleStart sealed class Expr data class Const(val number: Double) : Expr() data class Sum(val e1: Expr, val e2: Expr) : Expr() object NotANumber : Expr() fun...
funlocationFlow(locationManager:LocationManager): Flow<Location> = callbackFlow { vallistener =object
AI代码解释 classSonconstructor(name:String,age:Int):Father(name,age){override funaction(){println("Son")}} 3 . 子类没有主构造函数 :如果没有主构造函数 , 那么子类必须有次构造函数 , 子类需要在次构造函数中定义需要的变量 , 其中的参数 , 可以直接传递给后面 super ( ) 委托调用的主构造函数 ; ...
CREATE_ADAPTER);if(!adapter.isInstance(tag)) {thrownewIllegalArgumentException(String.format("`The found tag instance cannot store %s as it is a %s", type.getSimpleName(), tag.getClass().getSimpleName()));}Object foundValue =
扩展名为.class的文件包含 Java 字节码 扩展名为.dex的文件包含 Dalvik 字节码 扩展名为.apk的文件包含AndroidManifest文件、资源和.dex文件 对于纯 Kotlin 项目,只会使用 Kotlin 编译器,但 Kotlin 也支持跨语言项目,在这种情况下,将同时使用两个编译器来编译 Android 应用程序,并且结果将在类级别合并。
// Kotlin,没有了冗余的findViewById,我们可以直接对资源id进行操作,也不需要匿名内部类的声明,更关注函数的实现本身,抛弃了复杂的格式classMainKotlinActivity:Activity(){override funonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)R.id.label.setText...
configureOrCreate( name, presets.getByName("android") as KotlinAndroidTargetPreset, configure ) 我们看到android是创建了个KotlinAndroidTarget对象。我们找到插件multiplatform的入口类:AbstractKotlinMultiplatformPluginWrapper: abstract class AbstractKotlinMultiplatformPluginWrapper :KotlinBasePluginWrapper{ ...
class TwoActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_two)initView()}private fun initView() {btnSendMessage.setOnClickListener {EventBus.post(Person(name = "朱江",age = 23))}}} ...
==> Preparing: SELECT t.`id`,t.`stars`,t.`title`,t.`create_time` FROM `t_topic` t WHERE t.`id` = ? LIMIT 1 ==> Parameters: 3(String) <== Time Elapsed: 15(ms) <== Total: 1 多表查询 Topic topic = entityQuery .queryable(Topic.class) .leftJoin(BlogEntity.class, (t,t1...
class Person{ fun eat(){ println("人需要吃饭") } } fun main(){ Person().eat() } 1. 2. 3. 4. 5. 6. 7. 8. 2. companion object实现static功能 使用companion object实现类似java中的static功能 class Person{ // 不需要创建爱你对象,可以直接使用类名.方法调用 ...