Object Oriented Programming: Unit IV: I/O, Generics, String Handling

Restrictions and Limitations

Generics | Java OOPs

In Java, generic types are compile time entities. The runtime execution is possible only if it is used along with raw type.Primitive type parameters is not allowed for generic programming.

Restrictions and Limitations

1. In Java, generic types are compile time entities. The runtime execution is possible only if it is used along with raw type.

2. Primitive type parameters is not allowed for generic programming.

For example: Stack<int> is not allowed.

3. For the instances of generic class throw and catch instances are not allowed.

For example:

public class Test<T> extends Exception

{

//code // Error:can't extend the Exception class

}

4. Instantiation of generic parameter T is not allowed.

For example:

new T() //Error

new T[10]

5. Arrays of parameterized types are not allowed.

For example:

new Stack<String>[10];//Error

6. Static fields and static methods with type parameters are not allowed.

Object Oriented Programming: Unit IV: I/O, Generics, String Handling : Tag: : Generics | Java OOPs - Restrictions and Limitations