Why should I care that Java doesn't have reified generics?

后端 未结 13 766
予麋鹿
予麋鹿 2020-11-28 02:59

This came up as a question I asked in an interview recently as something the candidate wished to see added to the Java language. It\'s commonly-identified as a pain that Jav

13条回答
  •  感情败类
    2020-11-28 03:21

    Something that all the answers here have missed that is constantly a headache for me is since the types are erased, you cannot inherit a generic interface twice. This can be a problem when you want to make fine grained interfaces.

        public interface Service {
               VALUE get(KEY key);
        }
    
        public class PersonService implements Service,
            Service //Can not do!!
    

提交回复
热议问题