Scala Tutorial

python

Scala is a multi-paradigm programming language designed to integrate features of object-oriented programming and functional programming.

Scala runs on the Java Virtual Machine and is compatible with existing Java programs.

Scala source code is compiled into Java bytecode, so it can run on the JVM and can call existing Java class libraries.


Who is this tutorial for?

This tutorial is suitable for developers who want to learn the Scala programming language from scratch. Of course, this tutorial also goes deeper into some modules so you can better understand the applications of Scala.



What you need to know before learning this tutorial

Before continuing with this tutorial, you should understand some basic computer programming terminology. If you have studied the Java programming language, it will help you understand Scala programming more quickly.

LearnJava Tutorial。


Your first Scala program: Hello World

The following is a typical Hello World program written in Scala:

Example (HelloWorld.scala)

object HelloWorld {
    def main(args: Array[String]): Unit = {
        println("Hello, world!")
    }
}

Run example »

Save the above code as a HelloWorld.scala file and run the above Scala program (you can also run it directly online):

$ scalac HelloWorld.scala  // 把源码编译为字节码
$ scala HelloWorld  // 把字节码放到虚拟机中解释运行

The output result is:

Hello, world!

Recommended related documents

The following is aScala Language Specification.pdfdocument that can be used as a learning reference:

Other extensions