scala变量的定义

以下是scala函数中对于变量的定义方式:
package scala20140826

object FirstStart {
	  def main(args: Array[String]) {
	    //val  definition
	    val msg="hello world"
	    println(msg)
	    val msg2: java.lang.String = "Hello again, world!"
	    println(msg2)
	    val msg3: String = "Hello yet again, world!"
	      println(msg3)
	    println(max(1, 2))
	    print(greet())
	  }
   	  //函数的定义
	  def max(x: Int, y: Int): Int = {
		if (x > y) x
		 else y
	  }
	  def greet() = println("Hello, world!")
  
}

 

你可能感兴趣的:(scala)