标签:
搭建环境请参考:
http://www.cnblogs.com/super-d2/p/4534208.html
1.交互式编程:
adeMacBook-Pro:ssdb-master apple$ scala Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_71). Type in expressions to have them evaluated. Type :help for more information. scala> object HelloWorld { | def main(args:Array[String]){ | println("Hello world!") | } | } defined object HelloWorld scala> HelloWorld.main(null) Hello world! scala> :q
2.编译并运行:
adeMacBook-Pro:scala_dev apple$ vim HelloWorld.scala
HelloWorld.scala
object HelloWorld { def main(args: Array[String]) { println("Hello, world!") } }
编译:
scalac HelloWorld.scala
运行:
adeMacBook-Pro:scala_dev apple$ scala HelloWorld
Hello, world!
3.导入java的类
import java.util.{Date, Locale} import java.text.DateFormat import java.text.DateFormat._ object FrenchDate { def main(args: Array[String]) { val now = new Date val df = getDateInstance(LONG, Locale.FRANCE) println(df format now) } }
参考网站:
http://scalachina.com/node/17
标签:
原文地址:http://www.cnblogs.com/super-d2/p/4537274.html