boolean temp1,temp2;
temp1 = true;
temp2 = temp1;
Log.d("rvg", "temp1:"+temp1+" temp2:"+temp2);
temp1 = false;
Log.d("rvg", "temp1:"+temp1+" temp2:"+temp2);
When i execute this, i got
temp1:true temp2:true
temp1:false temp2:true
But i've Changed to array
boolean[] Temp1,Temp2;
Temp1 = new boolean[1];
Temp2 = new boolean[1];
Temp1[0] = true;
Temp2 = Temp1;
Log.d("rvg", "Temp1:"+Temp1[0]+" Temp2:"+Temp2[0]);
Temp1[0] = false;
Log.d("rvg", "Temp1:"+Temp1[0]+" Temp2:"+Temp2[0]);
When i execute this, i got same value for Temp1 and Temp 2.
Temp1:true Temp2:true
Temp1:false Temp2:false
What to do to avoid this?
Temp2[0] = Temp1[0];instead ofTemp2 = Temp1;