I just wonder what usage the following code has:
public class Sub extends java.util.ArrayList<String> {...}
There is no any compiling restriction on the generic constraint java.util.ArrayList<String>.
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.
Let’s say you were making an index for a book, but you don’t know how many indices you will need. You could make a class
BookIndex extends ArrayList<String>or if you want to get really picky:BookIndex extends ArrayList<IndexEntry>./e1
Also, when a one Class extends a generic Class like
ArrayList<String>you can grab theStringout from the generic declaration, unlike if you had a classArrayList<T>. InArrayList<T>you would never be able to figure out what theTis.