首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

scala 入门示范注意事项

2012-09-01 
scala 入门示例注意事项scala 执行模式有如下三种,脚本,对象,猜想,默认是第三种.Option -howtorun allows

scala 入门示例注意事项
scala 执行模式有如下三种,脚本,对象,猜想,默认是第三种.
Option -howtorun allows explicitly spe
    script: it is a script file
    object: it is an object name
    guess: (the default) try to guess

当我们写scala脚本的时候.

如果hello.scala文件只有如下代码,scala将识别为script方式执行
1. println("hello world") 
执行脚本方式的scala代码,只要直接输入:
scala hello.scala

如果hello.scala写成如下代码,scala将识别为object方式执行
object HelloWorld { 
def main(args: Array[String]) { 
println("hello world") 


执行对象方式的scala代码,首先需要编译:
scalac hello.scala
然后才能执行
scala  -classpath ./ HelloWorld

热点排行