Category Java

Generic Interface in Java with Example

Similar to generic class, when an interface is defined using generic type parameter, it is called generic interface in Java. When a generic interface is implemented by either a generic class or non-generic class, the type argument must be specified.…

Generic Constructor in Java

When we define a generic type parameter to the constructor of a class, it is called generic constructor in Java. We can use a generic constructor for both generic and non-generic classes. The general syntax to define a generic constructor…

Generic Class in Java

A class that is declared generic type is called generic class in Java. It is type-safe and can act upon any data type. A generic class is also called “parameterized types” because it uses a parameter that determines which data…

Generics in Java

Generics in Java with realtime example

Generics in Java is a mechanism that allows writing code for one type (say T) that is applicable for all types of data, instead of writing separate classes for each type. Let’s understand it with the help of an example.…

How to Create Arrays of Objects in Java

Arrays of objects in Java

In this tutorial, we will learn how to create arrays of objects in Java with the help of example programs. So far, we have studied in the previous tutorial that an array in Java is an ordered, sequential group of…