mercredi 13 février 2019

what's the usecase for int.class, double.class?

I understand the class literals and the getClass() methods how they help with generics and reflection but I don't understand why the same would apply for primitives as well?

For example, for int, I can use int.class but not sure what you could do with it.

  1. You cannot instantiate via int.class.newInstance(), it will throw an Exception
  2. You cannot use them with generics since those require non-primitives

Any ideas?





Aucun commentaire:

Enregistrer un commentaire