Lombok "val" example

"val" can use as the type of a local variable declaration instead of actually writing the type.

Java With out Lombok

public class ValExample {
  public void example() {
    ArrayList<String> example = new ArrayList<String>();
    example.add("Hello, World!");
    String foo = example.get(0);
  }
}

Java With Lombok

import java.util.ArrayList;
import java.util.HashMap;
import lombok.val;

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

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation