Lombok "val" example
"val" can use as the type of a local variable declaration instead of actually writing the type.
public void example() {
ArrayList<String> example = new ArrayList<String>();
example.add("Hello, World!");
String foo = example.get(0);
}
}
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
Post a Comment