kotlin泛型基本使用
class box<T> (t :T){ var vlaue =t }
fun main(arg: Array<String>) { val box1:box<Int> = box(20) val box2:box<String> = box("haha") println(box1.vlaue) print(box2.vlaue) }
最后,关注【码上加油站】微信公众号后,有疑惑有问题想加油的小伙伴可以码上加入社群,让我们一起码上加油吧!!!
class box<T> (t :T){ var vlaue =t }
fun main(arg: Array<String>) { val box1:box<Int> = box(20) val box2:box<String> = box("haha") println(box1.vlaue) print(box2.vlaue) }