class Config {
companion object {
//type constant
const val MAX_CONNECTIONS = 3
//type fields
var host = ""
var port = 52
//type method
fun getConnection(): String {
return "$host:$port"
}
//type constructor
init {
host = "10.0.0.1"
}
}
}
val connection1 = Config.getConnection()
//connection is "10.0.0.1:52"
Config.host = "10.0.0.3"
val connection2 = Config.getConnection()
//connection is "10.0.0.3:52"
println(connection1)
println(connection2)