Programming in Java: Interfaces vs Generics? on newest questions tagged java – Stack Overflow
I have some work code whereby using generics has started to make the code look more confusing than it should.
Is it possible that I do away with generics and use interfaces for member types, constructor types, method parameter types and method return types?
What would generic provide, that the above using interfaces would not? I understand generics does compile-time checking when retrieving elements (to stop wrong casting- like in the old days), but wouldnt the compiler detect if I tried inserting types which were not a sub type of the interface required?
Programming in Java: programming-in-java