Files
lombok/usage_examples/valExample_pre.jpage
T
Reinier Zwitserloot 7dba9c850c Added 'val' as a type which the 'val' fake keyword must resolve to before val works,
as a gesture to make val less 'magical'. It even works, in eclipse. Next up: javac.
2010-11-29 16:43:36 +01:00

22 lines
489 B
Plaintext

import java.util.ArrayList;
import java.util.HashMap;
import lombok.val;
public class ValExample {
public String example() {
val example = new ArrayList<String>();
example.add("Hello, World!");
val foo = example.get(0);
return foo.toLowerCase();
}
public void example2() {
val map = new HashMap<Integer, String>();
map.put(0, "zero");
map.put(5, "five");
for (val entry : map.entrySet()) {
System.out.printf("%d: %s\n", entry.getKey(), entry.getValue());
}
}
}