If you are using java 7, Type inference doesn't apply here. You have to provide the Type parameter in the constructor invoking as well.
Foo<String> foo = new Foo<String>() {
public void bar(String s, String t) {
System.out.println(s);
System.out.println(s);
}
};
foo.bar(hi,bye);
EDIT: just noticed that you have used new Foo()
which is basically a raw type, you have to provide the generic type for your constructor invokation, new Foo<String>()