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

  • Home
  • SEARCH
  • 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 6102631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:38:11+00:00 2026-05-23T13:38:11+00:00

Again I’m facing issues with generics, I thought I now know how to do

  • 0

Again I’m facing issues with generics, I thought I now know how to do this. To illustrate I created this simple example.

Given this interface

public interface Converter<A, B> {
    B encode( A a);
}

why does the following error:

void onRequest(ArrayList<String> a,Converter <? extends List<String>,String> conv) {
    conv.encode(a);
}

I expected that, with this notation, conv.encode would accept any param that extends List

any ideas?

  • 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-23T13:38:11+00:00Added an answer on May 23, 2026 at 1:38 pm

    Change it to:

    void onRequest(ArrayList<String> a,Converter <? super List<String>,String> conv) {
        conv.encode(a);
    }
    

    You want to call encode with an ArrayList, therefore ArrayList has to be a subclass of the furst type parameter of Converter. Therefore this first type parameter has to be a super class of ArrayList. By making it be super of List this is automatically guaranteed.

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

Sidebar

Related Questions

again. Right now I'm having issues with some pretty basic functionality in PHP. I
Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
Hi Again Masters Of The Web :) Now, I have got a new stupid
AGAIN: If you're voting -1, please leave a comment explaining why. This post isn't
Again a simple thing. I have a stylesheet that parses XML and XSL files.
Again, I'm here looking for your wisdom, in this case, I need to learn
again, this qn was from the practice qns in the mysql certification guide book
Again me with my divs =(. I have this: <div id=header></div> <div id=body> <div
Again, I'm trying to make a simple program. It will read some kind of
again im having a issues, I'm trying to get when a menu item is

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.