Scala Tutorial


scala-icon.png

Scala is a multi-paradigm programming language, designed to integrate various 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 call existing Java class libraries.


Who is suitable to read this tutorial?

This tutorial is suitable for developers who want to learn the Scala programming language from scratch. Of course, this tutorial will also go into depth on some modules to give you a better understanding of Scala applications.



What you need to know before following this tutorial

Before proceeding with this tutorial, you should know some basic computer programming terminology. If you have learned the Java programming language, it will help you understand Scala programming faster.

Learn Java Tutorial.


The first Scala program: Hello World

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

Example

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

Run instance»

Click the "Run instance" button to view the online instance

Save the above code as HelloWorld.scala file and execute the above scala Program (you can also execute it directly online):

$ scalac HelloWorld.scala
$ scala HelloWorld.scala

The output result is:

Hello, world!

Recommended related documents

The following is a Scala language specification.pdf document , can be used as a learning reference: