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 7178425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:55:08+00:00 2026-05-28T16:55:08+00:00

What is wrong with Class A below that won’t allow it to compile? public

  • 0

What is wrong with Class A below that won’t allow it to compile?

public class GenericsHell {
   interface Shape{} 
   interface Circle extends Shape {} 

   interface ShapeHelper<T extends Shape> {
      void draw(T shape);
   }

   class A<T extends Shape> {
      A(T shape, ShapeHelper<? extends Shape> helper) {
         helper.draw(shape); // Issues not-applicable argument error 
      }
   }

   class B {
      B(Circle circle, ShapeHelper<Circle> helper) {
         helper.draw(circle);
      }
   }
}   

Eclipse gives the following error:

The method draw(capture#1-of ? extends Shape) in the type ShapeHelper<capture#1-of ? extends Shape> is not applicable for the arguments (T)

  • 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-28T16:55:09+00:00Added an answer on May 28, 2026 at 4:55 pm

    The method draw(capture#1-of ? extends GenericsHell.Shape) in the type GenericsHell.ShapeHelper<capture#1-of ? extends GenericsHell.Shape> is not applicable for the arguments (T)

    The problem is that in your declaration, shape is of type T, but you request a ShapeHelper of type <? extends Shape> which means that one could pass as argument a ShapeHelper where S and T are distinct.

    You would then call helper<S>.draw(shape<T>); which doesn’t make sense.

    A correct implementation for this method would be:

    class A<T extends Shape> {
      A(T shape, ShapeHelper<T> helper) {
        helper.draw(shape); 
      }
    }
    

    Which ensures that the shape and the shape helper are of compatible types.

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

Sidebar

Related Questions

I wonder if there is something wrong with the copy constructor function below? class
The test class below verifies that a simple HttpService gets content from a given
I have the following code below that is meant to change a class var
I have a field in my model class like below: [ScaffoldColumn(false)] public DateTime DatePosted
I have a template file: 'template.txt' like below: class Core_Model_DbTable_{table_name} extends YouNet_Db_Table { const
I have a simple example below that does not compile. i get the following
What am I doing wrong here: class Helo { // main: generate some simple
Is there anything wrong with having a single class (one .h) implemented over multiple
I'm calling this linear class relationship , but correct me if I'm wrong. I'm
Maybe I'm thinking about this the wrong way but here's the idea: Class A

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.