I have changed hashmap into collection,collection into object,now I need object into String.either this way or any better way than this would be really appreciable.
Collection<String> t;
Collection<String> n;
String[] names;
String[] types;
Object[] foo;
Object[] doo;
HashMap<Integer, String> typehashmap=new HashMap<Integer, String>();
HashMap<Integer, String> namehashmap=new HashMap<Integer, String>();
t= typehashmap.values();
n= namehashmap.values();
foo=t.toArray();
doo=n.toArray();
for(int i=0;i<t.size();i++){
error--> types[i]=(String) foo[i];
error--> names[i]=(String) doo[i];
}
Assuming that the “error” is an ArrayIndexOutOfBoundsException”, you need to allocate the arrays before you add anything to them. There is also another toArray method that can help: