class Bank_ {
fun main(args: Array<String>) {
private val bank_name:String
private val bank_country:String
private val ank_address:String
private val bank_code:Int
}}
答案 0 :(得分:1)
那是因为这是真的。您不能在方法内部将变量声明为private
。
但是,您可以在这样的课堂上这样做:
class Bank {
private val name: String = ...
private val country: String = ...
private val address: String = ...
private val code: Int = ...
}
或者您宁愿使用数据类:
data class Bank(
val name: String,
val country: String,
val address: String,
val code: Int
)
...或这样的方法级别:
fun main(args: Array<String>) {
val name: String
val country: String
val address: String
val code: Int
}