Created
May 15, 2013 16:56
-
-
Save samandmoore/5585466 to your computer and use it in GitHub Desktop.
java doesn't have var, so if you want to type less, you have to create a static factory...
This file contains hidden or 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
| // problem | |
| Map<String, List<String>> map = new HashMap<String, List<String>>(); | |
| // -------------------------------------------------- | |
| // Java solution | |
| public static <K, V> HashMap<K, V> newHashMap() { | |
| return new HashMap<K, V>(); | |
| } | |
| // Java result | |
| Map<String, List<String>> map = newHashMap(); | |
| // -------------------------------------------------- | |
| // C# solution | |
| the `var` keyword for type inference... | |
| // C# result | |
| var map = new Map<String, List<String>>(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment