previous
|
start
|
next
Generic Methods
When calling a generic method, you need not instantiate the type variables:
Rectangle[] rectangles = . . .;
ArrayUtil.print(rectangles);
The compiler deduces that
E
is
Rectangle
You can also define generic methods that are not static
You can even have generic methods in generic classes
Cannot replace type variables with primitive types
e.g.: cannot use the generic
print
method to print an array of type
int[]
previous
|
start
|
next