Skip to content

Instantly share code, notes, and snippets.

@dain
Created April 20, 2011 23:43
Show Gist options
  • Save dain/933354 to your computer and use it in GitHub Desktop.
Save dain/933354 to your computer and use it in GitHub Desktop.
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