Is it possible to store a reference to a class in java(for example String), similar to python:
Java:
class Cl {
//
}
ArrayList<somethinghere> a;
a.add(Cl);
Python
class Cl:
pass
A=[Cl]
Something like this:
Class<String> clazz = String.class
Class<Cl> clazz2 = Cl.class;
List<Class<Cl>> list = new ArrayList<>();
list.add(clazz2);
clazz() gives some errorsYou can get the Class instance for your class using the static field class.
In your case Cl.class is the value you want.
This can be stored in a variable of type Class<?> or in a List<Class<?>>
Class<?> clazz = Test.class;
Cl.class. This could be stored in aList<Class<?>>