[Solved] What does this Java syntax mean? (` Class


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> where T is a type. By writing Class<?>, you’re declaring a
Class object which can be of any type (? is a wildcard). The Class
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 clazz`)