YouTube Link: https://youtu.be/9Tb-DyCirbA
** Java Certification Training: https://www.edureka.co/java-j2ee-training-course **
This Edureka PPT on Generics in Java will talk about what is generics, its methods, functions, etc. It will also showcase a demo to help you understand Java Generics concepts in a detailed way. Below topics are covered in this PPT:
What is Generics in Java?
Why Generics?
Types of Generics in Java
Generic Functions
Advantages of Generics in Java
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
What are Generics in Java | Java Generics Tutorial | Edureka
1.
2. WHAT IS GENERICS IN JAVA?
TYPES OF JAVA GENERICS
GENERIC FUNCTIONS
ADVANTAGES OF GENERICS IN JAVA
WHY GENERICS?
www.edureka.co/java-j2ee-soa-training
4. WHAT IS GENERICS IN JAVA?
Generics is a term that denotes a set of
language features related to the definition and
use of Generic types and methods.
www.edureka.co/java-j2ee-soa-training
7. TYPES OF JAVA GENERICS
www.edureka.co/java-j2ee-soa-training
8. TYPES OF
JAVA
GENERICS
Generic Type Class
class Genericclass{
private Object x;
public void set(Object x) { this.x = x; }
public Object get() { return x; }
}
www.edureka.co/java-j2ee-soa-training
9. TYPES OF
JAVA
GENERICS
Generic Type Interface
interface GenericInterface<T1, T2>
{
T2 PerformExecution(T1 x);
T1 ReverseExecution(T2 x); }
class Genericclass implements
GenericInterface<String, Integer> {
public Integer PerformExecution(String x)
{//execution code }
public String ReverseExecution(Integer x)
{ //execution code }
}
www.edureka.co/java-j2ee-soa-training
10. TYPES OF
JAVA
GENERICS
Generic Type Method
public static <T> int countAllOccurrences(T[]
list, T element) {
int count = 0;
if (element == null) {
for ( T listElement : list )
if (listElement == null)
count++;
}
else {
for ( T listElement : list )
if (element.equals(listElement))
count++;
}
return count;
}
www.edureka.co/java-j2ee-soa-training
11. TYPES OF
JAVA
GENERICS
Generic Type Constructor
class Dimension<T> {
private T length;
private T width;
private T height; }
public Dimension(T length, T width, T height){
super();
this.length = length;
this.width = width;
this.height = height;
}
www.edureka.co/java-j2ee-soa-training
13. GENERIC FUNCTIONS
We can also write generic functions that can be
called with different types of arguments based
on the type of arguments passed to generic
method, & further the compiler handles each
method.
www.edureka.co/java-j2ee-soa-training
15. ADVANTAGES OF
GENERICS IN
JAVA
Code Reusability
Type Safety
Individual type casting not required
Implementing non generic algorithms
www.edureka.co/java-j2ee-soa-training