Created
March 13, 2016 17:59
-
-
Save Makesh/a1defe6f1e2692aaa196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------ Pre Java 8 --------------------- | |
Map<Employee, File> fileMap = new HashMap<Employee, File>(); | |
int i =0; | |
for (Map.Entry<Employee, File> entry : map.entrySet()) { | |
i++; | |
// do something with i | |
} | |
------------------ Java 8 Lambda --------------------- | |
AtomicInteger counter = new AtomicInteger(0); | |
fileMap.forEach((k, v) -> { | |
counter.addAndGet(1); | |
//do something with i | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use also
counter.getAndIncrement();
instead ofcounter.addAndGet(1);