I have a Class> reference for an arbitrary type. How to get that type\'s initialisation value? Is there some library method for this or do I have to rol
Class>
You can use Defaults class from guava library:
public static void main(String[] args) { System.out.println(Defaults.defaultValue(boolean.class)); System.out.println(Defaults.defaultValue(int.class)); System.out.println(Defaults.defaultValue(String.class)); }
Prints:
false 0 null