Skip to content

Instantly share code, notes, and snippets.

@amontalenti
Created December 24, 2013 14:53
Show Gist options
  • Save amontalenti/8114359 to your computer and use it in GitHub Desktop.
Save amontalenti/8114359 to your computer and use it in GitHub Desktop.
example illustrating the complete lack of lightweight data modelling in Java
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);
}
}
}
@amontalenti
Copy link
Author

Clojure, a bit closer to other examples: https://gist.github.com/amontalenti/8117294

@lgastako
Copy link

Here's a version in haskell, though I am not really a haskeller, so I'm sure it can be better: https://gist.github.com/lgastako/8117999

@amontalenti
Copy link
Author

@asimjalis
Copy link

You can do lists this way to make it more concise.

List<Integer> someItems = Arrays.asList(1, 2, 3, 4);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment