Java SE 10 & 11: Developer features

Daniel S. Blanco
3 min readMay 5, 2022

In this post we will list mainly focused on the improvements for developers. With the idea of continuing to catch up a bit and at least know how to handle the new and most important features. So we will not go into detail about performance improvements or other less striking features.

Version 10 was the last one released by Oracle for free. And 11 was the next LTS after Java 8 and the first with the new licensing system model. Oracle also created a new release model, releasing a new version every 6 months. Because of that, version 10 was released in March 2018 and 11 in September 2018.

  • Java 10: var type local
    We can now initialize a variable without indicating specifically what type it is. As if it were an untyped programming language.
var s = "this is a String object";

With some exceptions, such as just declaring it, using it to store a lambda expression or initializing an array.

//cannot infer type for local variable
var a;
var b = null;
var c = () -> { };
var d = { 1 , 2 };
  • Java 10: Immutable methods
    Now the interfaces List, Map and Set have the new method copyOf that allows the creation of copies of lists that at the same time are immutable. And the method toUnmodifiableList/Map/Set in the Collectors interface.
  • Java 10: New Optional method
    There is now the new orElseThrow() method which is exactly the same as get() but with a more explanatory name.
String str = "str";
Optional<String> opt = Optional.ofNullable(str);
System.out.println(opt.orElseThrow()); // same as opt.get()
  • Java 10: Default certificates
    Oracle and Open JDK versions will now come with a default set of trusted entity certificates. Putting an end to TLS problems when using OpenJDK on the way.
  • Java 10: New versioning of Time-based releases
$ java -version
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
  • Java 11: New String methods
    New utility methods have been incorporated into the String class itself. strip() is an enhancement of trim().
  • Java 11: Var in Lambdas expressions
    We already indicated above that one of the great features of Java 10 was the local variable syntax. Now we can use them in lambdas.
Map<String, Integer> map = new HashMap<>();
map.put("2", 2);
// prints 22
map.forEach((final var x, final var y) -> System.out.println(x+y));
  • Java 11: Making it easier to read and write String in files
    The readString writeString methods have been created to allow this.
Path filePath = Files.writeString(Paths.get("tmp.txt"), "Sample text");
String fileContent = Files.readString(filePath);
// prints true
System.out.println(fileContent.equals("Sample text"));
  • Java 11: Nested members
    From now on, netmates concepts are incorporated and access between them is improved.
  • Java 11: HTTPClient Standardization
    Introduced in Java SE 9 now becomes a standard.
  • Java 11: Compiling and executing classes with a single command
java HelloWorld.java
  • Java 11: Removal of Java EE and CORBA modules
    They were already deprecated in Java SE 9 and now they have been removed: java.xml.ws, java.xml.bind, java.activation, java.xml.ws.annotation, java.corba, java.transaction, java.se.ee, jdk.xml.ws, jdk.xml.bind.

If you want to see all the specifications of Java 10 SE you can see them here and those of Java SE 11 here.

--

--