Scala Tutorial
Scala is a multi-paradigm programming language, designed to integrate the features of both object-oriented 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 libraries.
Who Should 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 delve into some modules to help you better understand the application of Scala.
What You Need to Know Before This Tutorial
Before proceeding with this tutorial, you should be familiar with some basic computer programming terminology. If you have studied the Java programming language, it will help you understand Scala programming more quickly.
Study the Java Tutorial.
Your First Scala Program: Hello World
Here is a typical Hello World program written in Scala:
Example (HelloWorld.scala)
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}
Save the above code as the HelloWorld.scala file, and execute the above Scala program (you can also run it online directly):
$ scalac HelloWorld.scala // Compile the source code into bytecode
$ scala HelloWorld // Interpret and run the bytecode in the virtual machine
The output result is:
Hello, world!
Recommended Related Documentation
The following Scala Language Specification.pdf document can be used for learning reference: