Ok, so the first parameter of the function is a List<E>
named Arraylist
(You shouldn’t capitalize variables in Java, name it as such arrayList
).
The second parameter is a Class<? extends E>
named clazz
.
Check manub’s explaination of Class<?>
:
Class
is a parameterizable class, hence you can use the syntax
Class<T>
whereT
is a type. By writingClass<?>
, you’re declaring a
Class
object which can be of any type (?
is a wildcard). TheClass
type is a type that contains meta-information about a class.
So now you know what Class<?>
means, but what about Class<? extends E>
?
<? extends E>
basically means any class which extends E (or E itself).
So Class<? extends E> clazz
means you have a varaible named clazz
which is E
class or a sub class of E
.
solved What does this Java syntax mean? (` Class extends E> clazz`)