Tags
#bloch-effective-java-2ed #java #java-generics
Question
a static method to swap two indexed items in a list:
public static void swap(List<?> list, int i, int j);
How would you write it with a type parameter?
Answer
public static <E> void swap(List<E> list, int i, int j);
Tags
#bloch-effective-java-2ed #java #java-generics
Question
a static method to swap two indexed items in a list:
public static void swap(List<?> list, int i, int j);
How would you write it with a type parameter?
Tags
#bloch-effective-java-2ed #java #java-generics
Question
a static method to swap two indexed items in a list:
public static void swap(List<?> list, int i, int j);
How would you write it with a type parameter?
Answer
public static <E> void swap(List<E> list, int i, int j);
If you want to change selection, open document below and click on "Move attachment"
pdf
owner:
piotr.wasik - (no access) - Effective Java (Joshua Bloch), 2ed, p139