What is a capture conversion in Java and can anyone give me examples?
问题 I've noticed JLS talks of 5.1.10 Capture Conversion, but I fail to understand what they are. Can anyone explain them to me/give examples? 回答1: Capture conversion was designed to make wildcards (in generics), ? useful. Suppose we have the following class: public interface Test<T> { public void shout(T whatever); public T repeatPreviousShout(); } and somewhere on our code we have, public static void instantTest(Test<?> test) { System.out.println(test.repeatPreviousShout()); } Because test is