Skip to content

Instantly share code, notes, and snippets.

@deda9
Forked from SamDeBlock/generics.java
Created July 11, 2016 15:37
Show Gist options
  • Save deda9/928298d36d10d3a65c1ff8d5dd7aaadb to your computer and use it in GitHub Desktop.
Save deda9/928298d36d10d3a65c1ff8d5dd7aaadb to your computer and use it in GitHub Desktop.
Generics
public class Generics {
static class Foo<T, R> {
public void bar(T arg) {
System.out.println("T " + arg);
}
public void bar(R arg) {
System.out.println("R " + arg);
}
}
public static void main(String[] args) {
Foo foo = new Foo<String, Long>();
foo.bar("abc");
foo.bar(123);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment