Map df = new HashMap();
df.put( "a ",new int[24]);
int[] count1=(int[])(df.get( "a "));
count1[1]=count1[1]+10;
int[] count2=(int[])(df.get( "a "));
System.out.println( "count= "+count2[1]);
Map df1 = new HashMap();
df.put( "a ", "12345 ");
String count11=(String)(df.get( "a "));
count11+= "yuiii ";
String count12=(String)(df.get( "a "));
System.out.println( "count12= "+count12);
打印出来的结果是
count=10
count12=12345
为什么df里面的值可以改变而df1就没改变
但换成
Map df = new HashMap();
df.put( "a ",new int[24]);
int[] count1=(int[])(df.get( "a "));
count1[1]=count1[1]+10;
int[] count2=(int[])(df.get( "a "));
System.out.println( "count= "+count2[1]);
Map df1 = new HashMap();
df.put( "a ",new String[24]);
String[] count11=(String[])(df.get( "a "));
count11[1]= "yuiii ";
String[] count12=(String[])(df.get( "a "));
System.out.println( "count12= "+count12[1]);
打印出来的结果是
count=10
count12=yuiii
这样为什么就可以改变呢?
急呀 |
|