Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

generics

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.

like image 845
Sanat Serikuly Avatar asked Oct 23 '25 21:10

Sanat Serikuly


1 Answers

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.

like image 193
fps Avatar answered Oct 26 '25 13:10

fps