emon
1/7/2020 - 5:46 PM

Lombok: final local variables

The existence of this type on a local variable declaration triggers both the adding of the final keyword as well as copying the type of the initializing expression which overwrites the 'fake' val type.

Source: https://projectlombok.org/features/val

public String example() {
  val example = new ArrayList<String>();
  example.add("Hello, World!");
  val foo = example.get(0);
  return foo.toLowerCase();
}