table of Contents
Notes on scala program development (emphasis)
Three ways to output scala language
Introduction
Scala is in a java virtual machine ( the JVM ) as the target operating the best characteristics of the environment and the object-oriented and functional programming static bonded together form typed programming language statement.
Features
- Scala is a multi-paradigm of formula (multi-paradigm) of programming language statements, Scala support support object-oriented and functional programming
- Scala source (.scala) are compiled into Java bytecode (.class) , then run on JVM on, and can call the existing Java class libraries, two languages to achieve seamless of contact.
- As a language, Scala is very simple and efficient
Quick start
Integrate scala environment in idea and build scala environment in windows, please check other materials by yourself.
Write the first helloworld program and run:
object hello {
def main(args: Array[String]): Unit = {
println("hello world")
}
}
Perform process analysis
If compiled with scalac, .class byte code will be generated, otherwise it will not be generated, and the byte code is generated directly in the memory.
Notes on scala program development ( emphasis )
- Scala source file to ".scala" extension
- Scala process execution entry sequence is main () function
- The Scala language is strictly case sensitive.
- Scala square method consists of a statement, every word after the sentence does not require a semicolon (Scala language will automatically add a semicolon after each line ) , which also reflects the Scala simplicity of.
- As if more than one statement on the same line, in addition to the last statement does not need to divide numbers, other statements require the semicolon ( try to write a statement on one line ) .
Three ways to output scala language
object hello {
def main(args: Array[String]): Unit = {
var name = "zhangsan"
var age = 18
println("name: "+name +" age: "+age)
printf("name: %s age: %d \n",name,age)
println(s"name: ${name},age: ${age}")
}
}
println("name:" + name + " age:" + age)
printf("name=%s, age=%d \n", name, age)
println(s"name=${name}, age=${age}")
scala comment
Single-line comments : // comment text word
Multi-line comments : / * Comment text * /
Document notes: / ** Note text * /
Scala's comments are completely similar to java comments