Unable to access current millisecond time in scala using java.lang.System.currentTimeMillis();

scala

Solution

It's the equal sign!

That's causing Scala to infer the return type of `main` to be `Long` (Scala) / `long` (at the JVM level). When you remove it, it infers `Unit` / `void`. Likewise when you remove the call to `currentTimeMillis`.

Problem

When I use below code in scala I get a runtime exception : java.lang.NoSuchMethodError: main Exception in thread "main" ``` object Driver { def main(args:Array[String]) = { java.lang.System.currentTimeMillis(); } } ``` But when I remove java.lang.System.currentTimeMillis(); the main method is found. Why is this ?

Original source