title: how to create a generic constructor for a generic class in java?
body: <p>I want to create a KeyValue class but in generic manner and this is what I've written:</p>
  
  <pre><code>public class KeyValue&lt;T,E&gt; 
  {
  
      private T key;
      private E value;
      /**
       * @return the key
       */
      public T getKey() {
          return key;
      }
      /**
       * @param key the key to set
       */
      public void setKey(T key) {
          this.key = key;
      }
      /**
       * @return the value
       */
      public E getValue() {
          return value;
      }
      /**
       * @param value the value to set
       */
      public void setValue(E value) {
          this.value = value;
      }
  
      public KeyValue &lt;T, E&gt;(T k , E v) // I get compile error here
      {
          setKey(k);
          setValue(v);
      }
  }
  </code></pre>
  
  <p>the error says : "Syntax error on token ">", Identifier expected after this token"</p>
  
  <p>how should I create a generic constructor in java then?</p>