Sanat Serikuly
Sanat Serikuly

Reputation: 187

How to pass the parameter of type Class<T[]> java

Playing with QueryDSL library.

Found interesting function

public static <T> ArrayConstructorExpression<T> array(Class<T[]> type, Expression... exprs)

I've never seen such a Generic as mentioned above. How can I pass the first parameter there?

Googling last hour, but no result for now.

Upvotes: 4

Views: 1107

Answers (1)

fps
fps

Reputation: 34460

Assuming T is of class Integer, you can do as follows:

ArrayConstructorExpression<Integer> arr = array(Integer[].class, someExpression);

There's no magic here. Integer[].class is the class that represents arrays of Integer objects.

Upvotes: 8

Related Questions