import static spark.Spark.* ;
public class HelloWorld {
public static void main(String[] args) { get("/hello", (req, res) -> "Hello World"); }
This is more simple as written in previous version and is also consistent with it as it can be written in Java 7 (or earlier) like this.
public static void main(String[] args) { get("/hello", new Route() { @Override public Object handle(Request req, Response res) throws Exception { return "Hello World"; } }); }
You can see how closures in Java actually represent more familiar idea and by omitting unnecessary ceremony do make writing in it more simple.
import static spark.Spark.* ;
public class HelloWorld {
}This is more simple as written in previous version and is also consistent with it as it can be written in Java 7 (or earlier) like this.
import static spark.Spark.* ;
public class HelloWorld {
}You can see how closures in Java actually represent more familiar idea and by omitting unnecessary ceremony do make writing in it more simple.