Könnte mir jemand anhand dieses Quellcodes sagen, was die Vorteile von Generics in diesem Fall ist?
ich würde sagen, dass durch Generics es sichergestellt wird, dass nur Elemente vom Typ E in der Liste enthalten sind.
Code (Java):
class Utilities<E>{
public List<E> operator(final List<E> a, final List<E> b){
final List <E> c= new LinkedList<>();
for(E e: a){
if(b.contains(e)){
c.add(e);...
public List<E> operator(final List<E> a, final List<E> b){
final List <E> c= new LinkedList<>();
for(E e: a){
if(b.contains(e)){
c.add(e);...
Generics & Collections
0 commentaires:
Enregistrer un commentaire