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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:35:27+00:00 2026-06-15T20:35:27+00:00

Java tutorial says that <?> and <T> are interchangeable. Why then can I compile

  • 0

Java tutorial says that <?> and <T> are interchangeable. Why then can I compile line 1 below, while I cannot compile line [2]?

abstract class A<K extends Number>{
  abstract public A<?> f(A<?> k); //[1]
  abstract public <S> A<S> f(A<S> k); //[2]
} 
  • 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-06-15T20:35:28+00:00Added an answer on June 15, 2026 at 8:35 pm

    After many hours of reading and searching, I have eventually found the answer to my own question.
    First of all, I have to say about <?>, there is some information here.

    So what is the supertype of all kinds of collections? It’s written
    Collection<?> (pronounced “collection of unknown”), that is, a
    collection whose element type matches anything.(Java tutorials)

    Ok, so our A<?> is super type of all kinds of As.
    And parametr A<?> can accept any of As (polymorphically) as a argument therefore line 1 compiles.
    Java tutorials

    Java specification tells us:

    Wildcards are a restricted form of existential types. Given a generic
    type declaration G<T extends B>, G<?> is roughly analogous
    to Some X<:B. G<X>

    B stands for bounds; X<:B indicates that the subtype relation holds between
    types X and B.

    Therefore A<?> is indeed auto-restricted;

    When we declare type argument <S>, it is, in some way, as if we declared class S{}, type S don’t have any relations to Number(our bound) and cast to one would fail, so we should declare that “S extends Number” to have the same effect as for <?>.

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

Sidebar

Related Questions

The Java Tutorial says that since an inner class is associated with an instance
The Java for C++ programmers tutorial says that (highlight is my own): The keyword
The Java Tutorial says that the static nested classes are accessed by using the
http://download.oracle.com/javase/tutorial/java/javaOO/nested.html says that static nested classes should be accessed this way: OuterClass.StaticNestedClass nestedObject =
I do tutorial in following link: Java RMI Tutorial After I compile successfully three
Please provide a good, thorough tutorial about Java class loading , focusing on how
First off, rest assured that I've read every Oracle Java article & tutorial about
The documentation for @ParametersAreNonnullByDefault says, that: This annotation can be applied to a package,
everything is the title java tutorial says: OuterClass.InnerClass innerObject = outerObject.new InnerClass(); this doesn't
In Deadlock section, Java SE 7 Tutorial, there is an example as shown below.

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.