Advance-Java Generic in Java #28

Publicado em: 23 Abril 2022
no canal de: King of Techniques
79
2

#java #javacourse #Generics #genericsin java

‪@kingoftechniques6864‬

Generics in Java are the advanced feature that helps to achieve code reusability and type safety. The code reusability functionality in java is managed by defining generic classes, interfaces, constructors, methods. Generic uses the data type declaration for a type safety feature that helps to eliminate the run time error.

The idea is to allow type (Integer, String, … etc, and user-defined types) to be a parameter to methods, classes, and interfaces. Using Generics, it is possible to create classes that work with different data types. An entity such as class, interface, or method that operates on a parameterized type is called a generic entity.

We can call the generics method by placing the actual type String and Integer inside the bracket before the method name. Note: We can call the generics method without including the type parameter. For example, In this case, the compiler can match the type parameter based on the value passed to the method.
Here, we are using the T type parameter to create the generic class of specific type. Let's see a simple example to create and use the generic class. The T type indicates that it can refer to any type (like String, Integer, and Employee). The type you specify for the class will be used to store and retrieve the data.


Nesta página do site você pode assistir ao vídeo on-line Advance-Java Generic in Java #28 duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário King of Techniques 23 Abril 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 79 vezes e gostou 2 espectadores. Boa visualização!