Within JLS Capture Conversion it discusses two ways to write the signature of the reverse
method:
public static void reverse(List<?> list);
public static <T> void reverse(List<T> list);
My question is why the second exposes implementation information to the caller ? Specifically within the example it says that the second is undesirable, as it exposes implementation information to the caller.
List<?> will return elements of type Object when iterating through the lyst. (eg: lyst.get(..) )
List<T> will return elements of Type T.
This helps to hide unneeded information to those implementing / using the interfaces.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.