English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Scala Tutorial

This tutorial is designed for beginners and can help them understand the basic knowledge of Scala through simple steps. After completing this tutorial, you will find that you have a moderate level of professional knowledge in using Scala, and you can take yourself to a higher level from here.

  

Scala is a multi-paradigm (multi-)-is a programming language of (programming paradigm) 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 can call existing Java class libraries.

Who is suitable for reading this tutorial?

This tutorial is suitable for developers who want to learn Scala programming language from scratch. Of course, this tutorial will also delve into some modules, allowing you to better understand the application of Scala.

What you need to know before learning this tutorial

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

Learn Java Tutorial.

The 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!")
    }
}
Test and see ‹/›

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

$ scalac HelloWorld.scala  // Compile the source code into bytecode
$ scala HelloWorld  // Place bytecode in the virtual machine for interpretation and execution

The output is:

Hello, world!

Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe manner. Scala was created by Martin Odersky, who2003The first version was released in the year. Scala smoothly integrates the features of object-oriented and functional languages. This tutorial introduces the basics of Scala in a simple and understandable way.