scala 中的类定义与getter setter

定义一个类,包含field以及方法函数 calss HelloWorld{this private var name  = "HEL"spa def sayHello(){print("HEllo,"+name)}   //在类中不叫函数 叫方法对象 def getName = nameget }class //建立类的对象,并调用其方法方法 val helloworld =new HelloWo
相关文章
相关标签/搜索