1.

What Is A Parameterized Or Generic Type?

Answer»

A generic type is a type with formal type parameters. A parameterized type is an instantiation of a generic type with actual type ARGUMENTS.

A generic type is a reference type that has one or more type parameters. These type parameters are later REPLACED by type arguments when the generic type is instantiated (or declared ). 

Example (of a generic type): 
interface Collection<E> {
public void add (E x);
public Iterator<E> iterator(); 
}



The interface Collection has one type parameter E . The type parameter E is a place holder that will later be replaced by a type argument when the generic type is instantiated and used. The instantiation of a generic type with actual type arguments is called a parameterized type 

Example (of a parameterized type): 

Collection<String> coll = NEW LinkedList<String>();

The declaration Collection<String> denotes a parameterized type, which is an instantiation of the generic type Collection , where the place holder E has been replaced by the concrete type String .

A generic type is a type with formal type parameters. A parameterized type is an instantiation of a generic type with actual type arguments.

A generic type is a reference type that has one or more type parameters. These type parameters are later replaced by type arguments when the generic type is instantiated (or declared ). 

Example (of a generic type): 
interface Collection<E> {
public void add (E x);
public Iterator<E> iterator(); 
}



The interface Collection has one type parameter E . The type parameter E is a place holder that will later be replaced by a type argument when the generic type is instantiated and used. The instantiation of a generic type with actual type arguments is called a parameterized type 

Example (of a parameterized type): 

Collection<String> coll = new LinkedList<String>();

The declaration Collection<String> denotes a parameterized type, which is an instantiation of the generic type Collection , where the place holder E has been replaced by the concrete type String .



Discussion

No Comment Found