The reason for the exception is that the class received by the call
list.getClass()
in line
System.out.println("size = " + list.getClass().getMethod("size").invoke(list));
- java.util.Collections $SynchronizedCollection. SynchronizedCollection Collections, , , .
- / - ( ), size() , obj.getClass() . , size() java.util.Collection() java.util.List.
"size = 1" :
System.out.println("size = " + Collection.class.getMethod("size").invoke(list));
System.out.println("size = " + List.class.getMethod("size").invoke(list));
, size(), , "", . size() - - Collection/List, size() SynchronizedCollection , . , .
, , - Collection size().