Trait similar to interface in Java but there are differences trait can inherit trait and in trait can write abstract methods, you can also implement the method instance as follows
Trait Walk
{
Def walk () {}
}
Class Person extends Walk
{
println ("Hello-----")
Override Def walk () {println ("Let's Have a Walk")}
}
Trait Run extends Walk
{
def run ()
{
println ("Gofor A walk and run around")
}
}
Object Hellotrait {
def main (args:array[string]): Unit = {
Val tt = Newperson with Run
Tt.run ()
}
}
Printing results:
Hello-----
Go for a walk and run around
Now is the best opportunity to learn big data, do not spend a penny can become big Data master, achieve 500,000 annual salary dream.
Liaoliang's first Chinese Dream: Free for the whole society to train 1 million outstanding big data practitioners!
If you are interested please click on this link to go to Big data learning
Http://blog.sina.com.cn/s/blog_8fbd39ee0102vto3.html
If you do feel that video tutorials are helpful, you can donate big data, Internet +, online, Industry 4.0, micro-marketing, mobile internet and other free combat courses through Liaoliang Teacher's number 18610086859
You can also focus on the DT Big Data dream factory through the following two-dimensional code
From big Data rookie to Master's journey Scala 12th lecture trait