Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 839201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:25:47+00:00 2026-05-15T05:25:47+00:00

This is a small snippet of code taken from some of the examples that

  • 0

This is a small snippet of code taken from some of the examples that accompany the Stanford Parser. I’ve been developing in Java for about 4 years, but have never had a very strong understanding of what this style of code is supposed to indicate.

List<? extends HasWord> wordList = toke.tokenize();

I’m not worried about the details of the code. What I’m confused about is what exactly the generic expression is supposed to convey, in English.

Can someone explain this to me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:25:47+00:00Added an answer on May 15, 2026 at 5:25 am
    ? extends HasWord
    

    means “A class/interface that extends HasWord.” In other words, HasWord itself or any of its children… basically anything that would work with instanceof HasWord plus null.

    In more technical terms, ? extends HasWord is a bounded wildcard, covered in Item 31 of Effective Java 3rd Edition, starting on page 139. The same chapter from the 2nd Edition is available online as a PDF; the part on bounded wildcards is Item 28 starting on page 134.

    Update: PDF link was updated since Oracle removed it a while back. It now points to the copy hosted by the Queen Mary University of London’s School of Electronic Engineering and Computer Science.

    Update 2: Lets go into a bit more detail as to why you’d want to use wildcards.

    If you declare a method whose signature expect you to pass in List<HasWord>, then the only thing you can pass in is a List<HasWord>.

    However, if said signature was List<? extends HasWord> then you could pass in a List<ChildOfHasWord> instead.

    Note that there is a subtle difference between List<? extends HasWord> and List<? super HasWord>. As Joshua Bloch put it: PECS = producer-extends, consumer-super.

    What this means is that if you are passing in a collection that your method pulls data out from (i.e. the collection is producing elements for your method to use), you should use extends. If you’re passing in a collection that your method adds data to (i.e. the collection is consuming elements your method creates), it should use super.

    This may sound confusing. However, you can see it in List‘s sort command (which is just a shortcut to the two-arg version of Collections.sort). Instead of taking a Comparator<T>, it actually takes a Comparator<? super T>. In this case, the Comparator is consuming the elements of the List in order to reorder the List itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a small snippet of code that I found. when we make a
I have this small snippet of python code that I wrote. It works, but
I have this small class called City that simply holds some information about a
I've found this small code that sends email to gmail users. I'd like the
I have written this small code snippet in C++, the output is also attached.
This is a small snippet of the code I am writing. It seems to
I have a small snippet of code. When I run this on my DevC++
I think this question is best asked with a small code snippet I just
I have a small snippet of code that assigns a prototype property and an
I have a small snippet of code here from something I designed but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.