java 8

How to iterate (loop) over the elements in a Map in Java 8

If you need to iterate over the elements in a Map in Java 8, this source code shows how to do it:

Map<String, String> map = new HashMap<String, String>();
map.put("first_name", "Alvin");
map.put("last_name",  "Alexander");

// java 8
map.forEach((k,v)->System.out.println("key: " + k + ", value: " + v));

Java architect's thoughts on Java 7 and Java 8

I just ran across this link in my email about the Chief Architect of the Java Platform Group at Oracle, with his thoughts about how to proceed on the Java 7 and Java 8 platforms releases. I haven't paid attention to the "New Java Features" world in a while, but it's a short, interesting read about how they're thinking about proceeding with the Java 7 and Java 8 platform releases.

Java 5 for loop syntax example (Java 5 Generics) alvin December 3, 2007 - 4:59pm

Java FAQ: Can you show me an example of the Java 5 for loop syntax? (Java 5 and newer)

Answer: Sure. I've created a sample Java program to demonstrate the Java 5 for-each loop syntax, using both a List with pre-Java5 syntax, and a second example using Java 5 generics syntax.

Java 5 for loop syntax example

Without any further ado, here is the example code: