Learn about Liaoliang's Scala class properties video lectures, which are summarized below:
The var variable has a default Java-like get and set method that does not need to be displayed, and the Val variable has a default Get method
Package Com.fish.scala
/**
* @author Fish
* @description life are short, you need spark!
* Big Data Architecture Consulting, welcome to contact @qq 16616365
*/
class classattr {
varname = "Yxg" //private[this] var name:string
Val Age = - //private[this] val age : Int
}
Object main {
var classattr = new classattr
println(classattr.name) //def name:string, here is the method called
println(classattr. Age) //val age : How is the Int called here not a method?
classattr.name="Good" //def name_= (x$1:string): Unit
//classattr.age = 101//variable is not allowed to be modified
}
teacher Wang's Scala classic lecture Baidu Cloud Disk:http://pan.baidu.com/s/1sjFpgL3
information from DT Big Data Dream Factory public account: Dt_spark
This article is from the Big Data Factory blog, so be sure to keep this source http://bigdatafactory.blog.51cto.com/2961711/1679478
DT Big Data Dream Factory 7th lecture-scala class properties