Wednesday, April 15, 2020

Newer Java

Java versions come so quickly it is hard to keep up. These days any language must have some sort of shell for REPL (Read Eval Print Loop). "jshell" is there since Java 9. I doubt anyone find that too useful.

I now have Java 11 (not even latest). And you can run your code even without compiling. And that deep down in everyone's heart everyone misses Pascal. now there is "var" to define variable without specifying the type just like many languages. Other dynamic typed languages like Javascript and Visual Basic has this for ages.

class Foo {
   public static void main(String arg[]) {
    var yes = true;
    System.out.println("Do you miss Pascal?"+ yes);
   }
}
I can run this with just "java Foo.java". I don't even need "javac" to compile it.

It compile behind the scene and does not even produce a .class file. This is a great write up of what's from 8 to 11. https://codete.com/blog/java-8-java-11-quick-guide/... but version 8 really was the major jump. Lambda and Streams and Optional stuff are just some of them. See here for a good list.

3 comments:

Packers And Movers Bangalore said...
This comment has been removed by a blog administrator.
Packers Movers Hyderabad said...
This comment has been removed by a blog administrator.
Packers And Movers Bangalore said...
This comment has been removed by a blog administrator.