Could you please explain to me why the following occors. What is this phenomena called so I can look it up further Thank you:
Date d1=new Date();
Date d2=d1;
d1.setTime(d1.getTime()+60*60*1000); // Changing d1 will automatically change d2. And visa versa.
System.out.println(d2);
System.out.println(d1);
int number1=7;
int number2=number1;
number1++;
System.out.println(number1+" "+number2); // Only number one is changed.
String str1="hiiiiii";
String str2=str1;
str1="hello";
System.out.println(str1+" "+str2); //Only str1 is changed.
Many thanks