title: Java Negative of a Number Instance
body: <p>I have a class like this:</p>
  
  <pre><code>public class SpiralGenerator&lt;E extends Number&gt; implements Iterator&lt;List&lt;E&gt;&gt; {
      private void generate(int pos, E... array) {
          if (pos == array.length) {
              List&lt;E&gt; list = new ArrayList&lt;&gt;();
              list.addAll(Arrays.asList(array));
              currentResults.add(list);
              return;
          }
          generate(pos + 1, array);
          array[pos] = -array[pos];
  
      }
  }
  </code></pre>
  
  <p>However it does not allow <code>array[pos] = -array[pos]</code>. If I use <code>Integer</code> instead of <code>E extends Number</code> it works fine.</p>
  
  <p>Error message:</p>
  
  <pre><code>bad operand type E for unary operator '-'
  where E is a type-variable:
  E extends Number declared in class SpiralGenerator
  </code></pre>
  
  <p>Why does the current approach not work, and how could I solve it?</p>