http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#currentTimeMillis()说:
以毫秒为单位返回当前时间.请注意,虽然返回值的时间单位是毫秒,但值的粒度取决于底层操作系统,并且可能更大.例如,许多操作系统以几十毫秒为单位测量时间.
我不清楚我是否保证这段代码将始终打印不断增加(或相同)的数字.
while (1) {
System.out.println(System.currentTimeMillis() );
}
Run Code Online (Sandbox Code Playgroud) 假设我有一些像这样的Scala代码:
// Outputs 1, 4, 9, 16, 25, 36, 49, 64, 81, 100
println( squares)
def squares = {
val s = for ( count <- 1 to 10 )
yield { count * count }
s.mkString(", ");
}
Run Code Online (Sandbox Code Playgroud)
为什么我必须使用临时val?我试过这个:
def squares = for ( count <- 1 to 10 )
yield { count * count }.mkString(", ")
Run Code Online (Sandbox Code Playgroud)
无法使用此错误消息进行编译:
error: value mkString is not a member of Int
def squares = for ( count <- 1 to 10 ) yield …
Run Code Online (Sandbox Code Playgroud)