0

In other words, check if a type is one of Integer, Double, Float, Long, Byte, Short, Boolean, Char

CaiNiaoCoder
  • 3,269
  • 9
  • 52
  • 82
  • 4
    Why do you even need that? Autoboxing and Unboxing works pretty well in Java. Can you describe your usage scenario? – MD Sayem Ahmed Nov 21 '13 at 08:09
  • 3
    Take a look at this question: http://stackoverflow.com/questions/709961/determining-if-an-object-is-of-primitive-type – Nikola Yovchev Nov 21 '13 at 08:10
  • I guessing you dont want to make a big if-else block with tons of instanceof tests? – Jakob Nov 21 '13 at 08:11
  • 2
    please vote to close. – CaiNiaoCoder Nov 21 '13 at 08:36
  • @Sayem when using reflection. java.lang.reflect.Field#getType return int.class for a int field and return Integer.class for a Integer Field, so I think we need to distinguish when int and integer are both allowed for a ambiguous field – CaiNiaoCoder Nov 21 '13 at 08:45
  • You can take a look at this question: http://stackoverflow.com/questions/709961/determining-if-an-object-is-of-primitive-type Or check Spring's ClassUtils: http://docs.spring.io/spring/docs/2.5.6/api/org/springframework/util/ClassUtils.html#isPrimitiveOrWrapper(java.lang.Class) – Nikola Yovchev Nov 21 '13 at 08:12

0 Answers0