标签:
import java.io.File object HelloWorld { def main(args:Array[String]): Unit = { for(i <- 1.to(3)) { println(i) } for(i <- 1 to 3) { println(i) } var files = (new File(".").listFiles()) for (file <- files) { println(file.getPath) } } }
var line = "" do { line = readLine(); println(" Your Input String is "+line) } while(line!="")
def main(args:Array[String]): Unit = { var arr = Source.fromFile("C:\\1.txt") for (line<-arr.getLines()) { println(line) } }
var array = Array(1,2,3,44,123,1231) for (i <- 0.until(array.length)) { println(array(i)) } }
var map = Map("name" -> "shaoyongyang", "age" -> 22, "sex" -> "boy") for ((k, v) <- map) { println(k , v); } for ((k,_) <- map) { println(k); }
def main(args:Array[String]): Unit = { def list(args:Int*) = { var result = 0 for (arg <- args) result +=arg result } println("Hello World"+ list(1,2,3,4,5,6)) }
def main(args:Array[String]): Unit = { lazy val l = 0 l + 1 println("Hello World " + l) println("Hello World " + l) }
标签:
原文地址:http://my.oschina.net/0x4ad/blog/520001