jeudi 5 janvier 2023

How to implement generic methods in java 8

I want to write the following similar methods.

method1:

public void method1(A a){
 //do some thing
}

method2:

public C method2(B b){
 //do some thing
}

method3:

public D method3(E b){
 //do some thing
}

the processing logic of the three interfaces method1, method2, and method3 is the same. I would like to ask whether these three methods can be abstracted by generic methods or design patterns.

Aucun commentaire:

Enregistrer un commentaire