Skip to main content

Timeline for Static method in a generic class?

Current License: CC BY-SA 2.5

4 events
when toggle format what by license comment
Jul 17, 2022 at 14:42 comment added themagicalyang @DavidRodríguez-dribeas makes valid point. The equivalent C++ code would work. I stumbled on this trying to make it work the C++ way and ofcourse it doesn't.
Jun 1, 2009 at 23:18 comment added user8681 I like this answer better than the accepted one... apart from the C++ template reference, the comment about the generic type only being for one instance of the class instead of the entire class is spot on. The accepted answer doesn't explain this, and just provides a workaround which doesn't have anything to do with why you can't use the class's generic type in a static method.
Jun 1, 2009 at 20:06 comment added David Rodríguez - dribeas Java generics are quite different from C++ templates. The generic class is compiled by itself. In fact the equivalent code in C++ would work (calling code would look like Clazz<int>::doIt( 5 ) )
Jun 1, 2009 at 19:43 history answered Marcin Cylke CC BY-SA 2.5