Getting started with spark to Mastery-(section II) Scala programming detailed basic syntax

Source: Internet
Author: User

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

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.