24.07.21 周总结(Kotlin学习)
本周Kotlin学习
学习内容以及笔记部分展示
部分练习代码展示
fun main () {
var stu1 = Student("xiaoming",13)
var stu2 = Student ("xiaohong",15)
println((stu1<stu2))
}
class Student(var name :String ,var age : Int ) {
operator fun compareTo(another:Student): Int {
return this.age-another.age
}
}
fun main () {
var stu = Student("",13)
var str :String ?= stu?.name ?:"空"
}
fun main () {
var stu = Student("xiaohong",16)
var (a,b)=stu
println("名字$a 年龄+100:$b")
}
class Student(var name :String ,var age : Int ) {
operator fun component1() = name+"hello"
operator fun component2() = age+100
}
Al问题解答
下周计划
利用Kotlin语言,实现cs构架