Created
April 20, 2011 23:43
-
-
Save dain/933354 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
import java.util.Arrays; | |
import java.util.Collection; | |
public class Glommer<T> | |
{ | |
public static <T> Glommer<T> glommer() | |
{ | |
return new Glommer<T>(); | |
} | |
String glom(Collection<?> objs) | |
{ | |
String result = ""; | |
for (Object o : objs) { | |
result += o; | |
} | |
return result; | |
} | |
int glom(Collection<Integer> ints) | |
{ | |
int result = 0; | |
for (int i : ints) { | |
result += i; | |
} | |
return result; | |
} | |
public static void main(String args[]) | |
{ | |
Collection strings = Arrays.asList("1", "2", "3"); | |
System.out.println(glommer().glom(strings)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment