2014年9月30日 星期二

Scala HelloWorld Example

[Software]
    Hadoop2.4.1
    Scala 2.10.4

[Hello World] by script
1. Create scala file "Hello.scala" as follow:

object Hello{
 def main(args: Array[String]) {
   println("Hello")
 }
}

2. Compile the scala file
- $ scalac Hello.scala
- It will create 2 files: Hello.class & Hello$.class

3. Execute(at the same dir with Hello.class)
[method 1]
- $ scala Hello.scala
[method 2]
- $ scala -cp . Hello

[Def]
- def : defines a method
- val : defines a fixed value (which cannot be modified)
- var : defines a variable (which can be modified)

沒有留言:

張貼留言