What are generics in Java?

Siva Prasad Nanda
Siva Prasad Nanda

Posted On: Apr 11, 2020

 

The Java Generics programming is included in J2SE 5 to administer with type-safe things. Generics in Java are related to templates in C++. The purpose is to concede class (String, Integer, and user-defined sorts) to denote a parameter to designs, types, and interfaces. For instance, states like HashMap, HashSet, ArrayList, etc utilize generics pretty well. We may utilize them for each kind. We may write a design/class/interface already and apply for all kind we require. Before Generics, we needed to typecast.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    HCL Java Developer Interview Questions

    What is Multithreading in Java?

    Multithreading is a programmable approach to achieve multitasking. Multithreading in Java is a process of executing multiple threads cumulatively. A thread is the smallest unit of processing which is ...

    HCL Java Developer Interview Questions

    What use of intern() method in String?

    In Java, intern() is a native method of the String class. The String.intern () returns a reference to the equal string literal present in the string pool. The intern () method is applicable to String ...

    HCL Java Developer Interview Questions

    What is Collection Framework?

    A Java collection framework is an architecture that was added to Java 1.2 version. The Collection Framework provides a well-designed set of classes and interfaces for storing and manipulating a group ...