[java] Hashmap
[java] Hashmap
salve ho un problema riguardo all'utilizzo di Hashmap
il codice incriminato è il seguente:
private HashMap registry = new HashMap();
(con il relativo import)
su windows (5.0) non mi da nessun errore
mentre su provo su linux (sempre 5.0) mi da un errore in fase di compilazione (con eclipse questo)
mi dice che
Multiple markers at this line:
the type Hashmap is not a generic: it cannot be parametrized with arguments (string, languageentity)
the type Hashmap is not a generic: it cannot be parametrized with arguments (string, languageentity)
non riesco proprio a capire
ho fatto anche qualche ricerca ma niente...
spero che possiate aiutarmi
grazie a chi mi risponderà
il codice incriminato è il seguente:
private HashMap registry = new HashMap();
(con il relativo import)
su windows (5.0) non mi da nessun errore
mentre su provo su linux (sempre 5.0) mi da un errore in fase di compilazione (con eclipse questo)
mi dice che
Multiple markers at this line:
the type Hashmap is not a generic: it cannot be parametrized with arguments (string, languageentity)
the type Hashmap is not a generic: it cannot be parametrized with arguments (string, languageentity)
non riesco proprio a capire
ho fatto anche qualche ricerca ma niente...
spero che possiate aiutarmi
grazie a chi mi risponderà
- 2>/dev/null
- Scoppiettante Seguace

- Messaggi: 271
- Iscrizione: sabato 5 novembre 2005, 21:30
Re: [java] Hashmap
package labss_minischeme.prototype;
import java.util.HashMap;
import java.util.Map;
import labss_minischeme.model.LanguageEntity;
public class PrototypeManager {
/**
* @uml.property name="registry"
* @uml.associationEnd qualifier="key:java.lang.Object labss_minischeme.model.LanguageEntity"
*/
private HashMap registry = new HashMap();
public LanguageEntity create(String name) {
LanguageEntity prototype = registry.get(name);
if (prototype == null)
throw new IllegalArgumentException("prototype sconosciuto: "+name);
return (LanguageEntity) prototype.clone();
}
public LanguageEntity create(String name, Object... args) {
LanguageEntity prototype = registry.get(name);
if (prototype == null)
throw new IllegalArgumentException("prototype sconosciuto: "+name);
LanguageEntity result=(LanguageEntity)prototype.clone();
if (args.length==2) {
result.set(0,(String)args[0]);
result.set(1,(LanguageEntity)args[1]);
}else result.set(0,args[0]);
return result;
}
public void put(String name, LanguageEntity prototype) {
LanguageEntity prototype1 = registry.get(name);
if (prototype1 != null){}
else registry.put(name, prototype);
}
public void remove(String name) {
registry.remove(name);
}
}
import java.util.HashMap;
import java.util.Map;
import labss_minischeme.model.LanguageEntity;
public class PrototypeManager {
/**
* @uml.property name="registry"
* @uml.associationEnd qualifier="key:java.lang.Object labss_minischeme.model.LanguageEntity"
*/
private HashMap registry = new HashMap();
public LanguageEntity create(String name) {
LanguageEntity prototype = registry.get(name);
if (prototype == null)
throw new IllegalArgumentException("prototype sconosciuto: "+name);
return (LanguageEntity) prototype.clone();
}
public LanguageEntity create(String name, Object... args) {
LanguageEntity prototype = registry.get(name);
if (prototype == null)
throw new IllegalArgumentException("prototype sconosciuto: "+name);
LanguageEntity result=(LanguageEntity)prototype.clone();
if (args.length==2) {
result.set(0,(String)args[0]);
result.set(1,(LanguageEntity)args[1]);
}else result.set(0,args[0]);
return result;
}
public void put(String name, LanguageEntity prototype) {
LanguageEntity prototype1 = registry.get(name);
if (prototype1 != null){}
else registry.put(name, prototype);
}
public void remove(String name) {
registry.remove(name);
}
}
Re: [java] Hashmap
vorrei far notare che sul portatile (dove ho sempre ubuntu) funziona tutto...però per necessità il java l'ho installato dal sito della sun (con la 5.05 avevo dei problemi)...non vorrei che c'entrasse quello...ma è strano
-
JavaForEver
- Prode Principiante
- Messaggi: 2
- Iscrizione: giovedì 16 marzo 2017, 17:40
Re: [java] Hashmap
Forse non hai definito i metodi equals e hashcode di LanguageEntity. Questo porta ad un conflitto.
Qua un esempio del problema delle collisioni:
<link rimosso dallo staff per spam>
Qua un esempio del problema delle collisioni:
<link rimosso dallo staff per spam>
- tokijin
- Moderatore Globale

- Messaggi: 4624
- Iscrizione: mercoledì 3 giugno 2009, 23:10
- Desktop: plasma 5.27.4
- Distribuzione: Kubuntu 23.04
- Località: Abruzzo
Re: [java] Hashmap
@JavaForEver
Controlliamo le date, non è bene riportare in vita una discussione ferma dal 2006.
Chiudo.
Controlliamo le date, non è bene riportare in vita una discussione ferma dal 2006.
Chiudo.
Sei abbruzzese se dopo che ti sei strafogato un chilogrammo di pasta, hai il coraggio di dire alla cuoca "cacc ch'è cott" - Se entra un piccione in casa..chiudi le finestre!
Ubuntu User #28657 - Il mio vecchio hardware - Tag Codice
Ubuntu User #28657 - Il mio vecchio hardware - Tag Codice
Chi c’è in linea
Visualizzano questa sezione: 0 utenti iscritti e 3 ospiti