G
Guest
Gast
Hallo Leute
ich moechte gerne eine Collection HashMap als Array implementieren,
so dass ich ueber col[0], col[1] auf die HashMaps zugreifen kann.
Ich habe zwei Implemantationen versucht.
Bei beiden beschwert sich eclipse nicht.
Aber bei beiden kommt eine Exception, wenn
ich den Code compilieren moechte.
HashMap[] test1 = new HashMap[2];
test1[0].put("1", "2");
HashMap[] test2 = {new HashMap(), new HashMap()};
test2[0].put("1", "2");
Fehlerausgabe :
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
List cannot be resolved to a type
Arrays cannot be resolved
Syntax error on token ")", delete this token
Collection cannot be resolved to a type
HashSet cannot be resolved to a type
at test.Array1.main(Array1.java:23)
Wie kann man denn eine Collection (Map) richtig als Array implementieren ?
danke Tracer
ich moechte gerne eine Collection HashMap als Array implementieren,
so dass ich ueber col[0], col[1] auf die HashMaps zugreifen kann.
Ich habe zwei Implemantationen versucht.
Bei beiden beschwert sich eclipse nicht.
Aber bei beiden kommt eine Exception, wenn
ich den Code compilieren moechte.
HashMap[] test1 = new HashMap[2];
test1[0].put("1", "2");
HashMap[] test2 = {new HashMap(), new HashMap()};
test2[0].put("1", "2");
Fehlerausgabe :
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
List cannot be resolved to a type
Arrays cannot be resolved
Syntax error on token ")", delete this token
Collection cannot be resolved to a type
HashSet cannot be resolved to a type
at test.Array1.main(Array1.java:23)
Wie kann man denn eine Collection (Map) richtig als Array implementieren ?
danke Tracer