Besides ensuring key is a String as compile type, is there any other advantage to it? or can it be left out? The value i am storing can be of multiple types
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Declaraing a
Mapwithout generic type information is deprecated and most IDEs are generating warning here. This is important left alone, even if it isMap<Object, Object>. Also ensuring the key is aStringat compile time is actually quite a lot.Technically the types are erased during compilation so there is no advantage while running the code. But again – since Java 5 you should always include generic type information.