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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:44:34+00:00 2026-05-17T16:44:34+00:00

Simple Java generics question: I have two classes – one of which uses generics

  • 0

Simple Java generics question: I have two classes – one of which uses generics to define its type, the other which extends this class providing a concrete type.

public class Box<Item> {
    ...
}


public class Toolbox extends Box<Tool>{
    ...
}

Given that Toolbox extends Box providing a Tool as the actual type for the generic placeholder, I would have thought it should be possible to do something like this:

Box<Tool> box = new Box();

Toolbox toolbox = box; 

However, it seems this causes a type-mismatch. Why is this?

  • 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-17T16:44:34+00:00Added an answer on May 17, 2026 at 4:44 pm

    Box<Item> is the unbound generic type. Box<Tool> is a particular bound version of that same generic type. Toolbox is a subclass of Box<Tool> and thus is a discrete type from Box<Tool>.

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

Sidebar

Related Questions

In general, is it a best practice to have simple POJO Java classes implement
I have a very simple Java RMI Server that looks like the following: import
I have a really simple Java class that effectively decorates a Map with input
I'm looking for a simple java lib/src to highlight differences between two Strings, case-sensitive.
I'm deploying a simple Java app to Google App Engine. I have a simple
I have a simple Java Swing GUI Form with a browse button. The browse
I'm storing a simple java.util.date in an Oracle XE database via hibernate. When testing
I've got a simple java class that looks something like this: public class Skin
I've been looking for a simple Java algorithm to generate a pseudo-random alpha-numeric string.
I've written a fairly simple java application that allows you to drag your mouse

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.