這裏我有兩個hashmaps dataz
和screen_dataz
。我想將screen_dataz
複製到dataz
。如何將一個hashmap內容複製到另一個hashmap
我想是這樣,但它不工作:
Object[] obj = new Object[5];
String[] strArray = new String[]{"Obj1","Array1","Converted1","To1","List1"};
String[] strArray1 = new String[]{"Obj2","Array2","Converted2","To2","List2"};
dataz.put(0,(Object[]) strArray);
dataz.put(1,(Object[]) strArray1);
// String dataString = (String) dataz;
System.out.println(dataz);
Object[] obj1= new Object[5];
String[] strArray2 = new String[]{"Obj3","Array3","Converted3","To3","List3"};
String[] strArray3 = new String[]{"Obj4","Array4","Converted4","To4","List4"};
screen_dataz.put(0,(Object[]) strArray2);
screen_dataz.put(1,(Object[]) strArray3);
System.out.println("copying screen dataz to dataz");
dataz.putAll(screen_dataz);
請出示'dataz'和'screen_dataz'的定義和解釋你的意思是「它不工作」。 –
對,直到我們定義了'dataz',下面的幾個答案可能是錯誤的! –