title: Java generics and simple types
body: <p>I was trying to write a generic class, that could operate on any simple type (int, float, etc.). I wanted to avoid repeating the same function several times, with changing the type of parameter. But since the generic parameter is a reference, I cannot do any calculations on variables of its type, like in C++ templates.</p>
  
  <p>So is there any simple way in Java to use arithmetic operators on generic type variables? I know that I could use class-checking, and casting, but I think it would be much more code, and impact on performance. However I only recently started to write in Java, so I may be wrong.</p>