Scala Tutorial
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 should read this tutorial?
This tutorial is suitable for developers who want to learn the Scala programming language from scratch. Of course, it also goes deeper into some modules to help you better understand Scala applications.
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 learned the Java programming language, it will help you understand Scala programming faster.
LearnJava Tutorial。
Your first Scala program: Hello World
The following is a typical Hello World program written in Scala:
Example (HelloWorld.scala)
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 is:
Hello, world!
Recommended related documentation
The following is aScala Language Specification.pdfdocument, which can be used as a learning reference:
Other extensions