1

My problem is not regarding the usage but of terminology. To put simply, who is generic, Type, Wildcard among them -

List<T> List<Integer> List<? extends Number> 

You can add your own examples too. I understand T will be Type , ? wildcard but then what is generic and what do we call Integer used here ?

2
  • all the three represent generic, T represent it can be of any type, and ? represent here that the list should be for some type of Number Commented Mar 22, 2017 at 10:18
  • 1
    Thanks for the super quick accept! Commented Mar 22, 2017 at 10:33

1 Answer 1

1

A good source of information would be the Oracle tutorials, like here:

public interface List <E> { void add(E x); Iterator<E> iterator(); } 

Those are the declarations of the formal type parameters of the interfaces List and Iterator.

But of course, the ultimate answers can be found in the JLS, like:

A class is generic if it declares one or more type variables

Or further down:

A method is generic if it declares one or more type variables

In other words: to really understand terminology, start reading the JLS, sections 8.1.2 and 8.4.4.

Beyond that: a more human readable but still in-depth introduction is the FAQ by Angelika Langer.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.