简体   繁体   中英

how can I instantiate a template class in java in a certain way?

I have a template class in Java, such as ArrayList. I want to create a class that extends the template class, while fixing SomeType to some type. Later, I want to be able to pass the non-templated new class as an argument to methods that originally accepted ArrayList. Is that possible? Thanks.

I believe you can. Check out this post at JavaRanch

What you're looking for is

public class MyList extends ArrayList<String>{
    //code
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM