【发布时间】:2011-12-27 00:32:30
【问题描述】:
我已将 hashmap 更改为集合,将集合更改为对象,现在我需要将对象更改为 String。无论是这种方式还是比这更好的方式都会非常明显。
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];
}
【问题讨论】:
-
如果您还用它所指的编程语言标记您的问题,那将非常有帮助。也许你应该告诉我们代码有什么问题;-)
-
运行时错误或编译器错误?
标签: object collections hashmap