Skip to main content
added 4 characters in body
Source Link
Andreas Fester
  • 36.8k
  • 9
  • 101
  • 125

Java doesn't know what TT is until you instantiate a type.

Maybe you can execute static methods by calling Clazz.doit(something)Clazz<T>.doit(something) but it sounds like you can't.

The other way to handle things is to put the type parameter in the method itself:

static <U> void doIt(U object) 

which doesn't get you the right restriction on U, but it's better than nothing....

Java doesn't know what T is until you instantiate a type.

Maybe you can execute static methods by calling Clazz.doit(something) but it sounds like you can't.

The other way to handle things is to put the type parameter in the method itself:

static <U> void doIt(U object) 

which doesn't get you the right restriction on U, but it's better than nothing....

Java doesn't know what T is until you instantiate a type.

Maybe you can execute static methods by calling Clazz<T>.doit(something) but it sounds like you can't.

The other way to handle things is to put the type parameter in the method itself:

static <U> void doIt(U object) 

which doesn't get you the right restriction on U, but it's better than nothing....

Source Link
Jason S
  • 190.6k
  • 176
  • 637
  • 1k

Java doesn't know what T is until you instantiate a type.

Maybe you can execute static methods by calling Clazz.doit(something) but it sounds like you can't.

The other way to handle things is to put the type parameter in the method itself:

static <U> void doIt(U object) 

which doesn't get you the right restriction on U, but it's better than nothing....