You can create a class in Java that defines one or more placeholders for data type. The placeholders are known as generics because the class is not determined until compile time. Generics are notated by angle brackets (). For example, we might wish to create a class that contains a method that accepts an argument of any data type and displays the value of the argument. Because we don’t know the data type when we are developing the class, we must use a generic for the method argument data type. To apply basic generics syntax in Java, follow these four steps.

Leave a Reply

Your email address will not be published. Required fields are marked *