What is Scala?
S-Cala is a language designed to achieve scaleable language. Officially, it is called the mixed language of object-oriented language and functional language.
Scala can be seamlessly spliced with Java programs, because Scala files are compiled as. class files and run on the JVM.
Spark was developed by Scala.
Scala installation?
Here's the process of installing Scala on CentOS, similar to installing a JDK.
Official website Download scala:http://www.scala-lang.org/download/
This is because it is a Linux version, so choose the tgz format. Then upload to the server.
[Email protected] ~]# Cd/home/software//Place the Scala package in the specified directory[Email protected] ~]# Tar-zxf/home/software//Unzip[[email protected] ~]# sudo mv scala-2.11.8/usr/Lib[[email protected]~]# sudo vim/etc/profile//Editing Environment Variables//at the end of the addExport Scala_home=/usr/lib/scala-2.11.8Export PATH= $PATH: $SCALA _home/bin//Save Exit Edit[[Email protected]~]# Source/etc/profile//effective[[Email protected]~]# scala-version
The following appears to indicate that the installation was successful. This is followed by some basic grammar learning in Scala.
val Variable declaration: declares a Val variable to hold the expression's computed result, which is immutable.
Val result = 1 + 1
- Subsequent constants are available for continuation, Eg:2 * result
- However, the Val constant declaration does not change its value, otherwise it returns an error.
var variable declaration: DECLARE var variable, can change the reference.
var result1 = 1; RESULT1 = 2
Specify Type : Whether you declare a Val variable or a var variable, you can manually specify the type, and the default Scala will determine its own type based on the value .
Null= "Leo"
declaring multiple variables: You can put multiple variables together for declaration.
Null= 100
Getting started with spark to Mastery-(section II) Scala programming detailed basic syntax