Bir KeyValue sınıfını ama genel bir şekilde oluşturmak istiyor ve bu yazdığım budur: "Bu belirteci sonra beklenen Tanıtıcı '>' Sözdizimi hatası belirteç üzerinde"java'da genel bir sınıf için genel bir kurucu nasıl oluşturulur?
:public class KeyValue<T,E>
{
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 <T, E>(T k , E v) // I get compile error here
{
setKey(k);
setValue(v);
}
}
hata diyor
java'da nasıl genel bir kurucu oluşturmalıyım?
@dasblinkenlight doğru cevabı vardır yazdı. Sadece istediğin şeyi yapmak istediğini AbstractMap.SimpleEntry yapmak istedim. –
user949300
Yeterince doğru olan biri, sorunun yazımını düzeltebilir mi? Mümkün –