> Maybe I missing something obvious but there seems to no way to do
> somehting like this (yes I know the syntex is illegal):
[quoted text clipped - 33 lines]
> of Foo (it contains nothing but static methods and the default/only
> constructor is private). How do set T at run time (syntatically?)
If the "foo" method is static, you should actually show that in your
example, otherwise you may confuse the people who are trying to help you.
If you're using Eclipse to compiler your code, the code you posted
should work. Eclipse can use the return type to infer the parameterize type.
If you're using Sun's compiler, you have to give a hint as to what the type
is. The typical way of doing that is to pass the type in as a class.
<code>
public <T> T foo(Class<? extends T> clazz) {
return clazz.cast(ack(this));
}
public void someMethodThatUsesFoo() {
String myString = foo(String.class);
}
</code>
- Oliver