java - Store a Map object inside another Map -
java - Store a Map object inside another Map -
i have instance map:
map<string, integer> map = new hashmap<string,integer>();
than set values:
map.put("a", 2); map.put("b", 3);
than have class serialize object:
public class mapobject implements serializable { private static final long serialversionuid = 1l; map<string, integer> map = new hashmap<string, integer>(); public mapobject(map<string, integer> map) { this.map = map; }
}
i because i'm working sockets , want pass map object client server using objectinputstream , objectoutputstream.
now want inquire if can store map object in server, instance
mapobject mo;
is possible store object in map?
regards
you mixing 2 questions together. don't know asking:
can transport hierarchical map thro objectoutputstream? how map map map?if asking question 2, should not mention mention question 1 because confuses question. or asking both questions?
answer question 2:
map<string, map<?,?>> mapofmap = new hashmap<string, map<?,?>>(); map<string, integer> mapa = new hashmap<string, integer>(); mapofmap.put("a", mapa);
answer question 1:
of course.
...
to reply farther questions:
set of keys , iterator,
set<string> keys = mapofmap.keyset(); iterator<string> iterator = keys.iterator();
look @ http://code.google.com/p/synthfuljava/source/browse/trunk/common/org/synthful/util/hashtreenode.java,
to see illustration of can done map of maps.
that tree hash node written (poorly) in 2004 (and needs have fluff tostringbuffer removed), adequately illustrate xpath addressable hash tree. have version gwt fluff removed somewhere else.
java sockets map hashmap objectinputstream
Comments
Post a Comment