DT Big Data Dream Factory 7th lecture-scala class properties

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.