我正在尝试将哈希图转换为数组,我可以将其放入创建的字符串数组中。然而,我得到了 java.lang。我已将我的 Drinkar.keySet().toArray() 类型转换为 String[],但它仍然无法正常工作。
public String[] receiveArrayList(){
String[] list = new String[0];
try {
ois = new ObjectInputStream(socket.getInputStream());
drinkar = (HashMap<String, ArrayList<String>>) (ois.readObject());
System.out.println(drinkar);
System.out.println(Arrays.toString(drinkar.keySet().toArray()));
list = (String[]) (drinkar.keySet().toArray());
for(int i = 0; i < list.length; i++){
System.out.println(list);
}
} catch (ClassNotFoundException ex) {
System.out.println(ex);
} catch (IOException ex) {
System.out.println(ex);
}
return list;
}