How to express an Array <T> .class

I have a method that needs an Object.class parameter like

 method(Object.class)

How can I set a class in an Array of this class? Sort of

 method(ArrayList<Object>.class)

I tried

 method(new ArrayList<Object>() {})

. He does not work.

+5
source share
2 answers

You can use Object[].class.

( int[].class, String[].class, double[][][].classEtc.).

+8
source

You can do this by expanding your own class from ArrayList

class UserList extends ArrayList<User>{}

Now you can do it

UserList.class
0
source

All Articles