Created
December 24, 2013 14:53
-
-
Save amontalenti/8114359 to your computer and use it in GitHub Desktop.
example illustrating the complete lack of lightweight data modelling in Java
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
import java.util.List; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Map; | |
import java.util.HashMap; | |
public class JavaMapsAndLists { | |
public static void main(String [] args) { | |
List<Integer> someItems = Arrays.asList(new Integer[] {1, 2, 3, 4}); | |
for (Integer item : someItems) { | |
System.out.println(item); | |
} | |
Map<String, String> someMapping = new HashMap<String , String>() {{ | |
put("ST", "started"); | |
put("IP", "in progress"); | |
put("DN", "done"); | |
}}; | |
for (Map.Entry<String, String> entry : someMapping.entrySet()) { | |
String key = entry.getKey(); | |
String value = entry.getValue(); | |
System.out.println(key + " => " + value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do lists this way to make it more concise.