我如何在 Kotlin 中添加人员列表?
How could I add a list of People in Kotlin?
我正在尝试创建一个包含姓名和特征的人员列表。
我该怎么做?
class Player(val name: String, val nachname: String, val nr: Int)
// And I'm trying to do this:
fun main() {
val team2 = mutableListOf<Player>()
team2.add("Max", "Mustermann", 12)
println("${team2.size}")
}
您正在寻找
team2.add(Player("Max", "Mustermann",12))
我正在尝试创建一个包含姓名和特征的人员列表。 我该怎么做?
class Player(val name: String, val nachname: String, val nr: Int)
// And I'm trying to do this:
fun main() {
val team2 = mutableListOf<Player>()
team2.add("Max", "Mustermann", 12)
println("${team2.size}")
}
您正在寻找
team2.add(Player("Max", "Mustermann",12))