I wonder why generic methods which return nothing void
are (or can be) declared this way:
public static <E> void printArray( E[] inputArray ) {
// Display array elements
for ( E element : inputArray ){
System.out.printf( "%s ", element );
}
System.out.println();
}
It seems like <E>
is the type of the returned object, but the method returns nothing in fact. So what is the real meaning of <E>
in this case specifically and in generic methods generally?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…