1. Translating Java Classes to Scala Classes Example 1: # a class declaration in Java public class Book{} # Scala equivalent of a class declaration class Book Example 2: # a Java class with a Construtor public class Book{ private final int isbn; priv…
1. Variables (1) Three ways to define variables: 1) val refers to define an immutable variable; scala> val x = x: Int = scala> x*x res4: Int = scala> res4 + # use result as a value res6: Int = scala> res4 + res6 res7: Int = scala> x = # x i…
String in Java is very special class and most frequently used class as well. There are lot many things to learn about String in Java than any other class, and having a good knowledge of different String functionalities makes you to use it properly. G…
1.模式匹配比java中的switch case强大很多,除了值,类型,集合等进行匹配,最常见的Case class进行匹配,Master.scala有大量的模式匹配. Case "_"表示不满足上面的所有情况的体验,举个例子: def bigdata(data: String){ data match{ case "Spack"=>println("WOW!!!") case "Hadoop"=>println(…