You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Lecture 49: Time: 1:00:00
Based on the code you provided, the output should be 1 and not 4. The reason for this is that when you create an array in Java, it creates a new object in memory to store the values in the array. So, when you assign arr to {1, 2, 3} and brr to {1, 2, 3}, you have two separate arrays in memory with the same values.
When you change the value of arr[0] to 4, it only affects the arr array and not the brr array. Therefore, when you print brr[0], it should still be 1.
However, if you had assigned brr to arr like this:
then the output would be 4 because both arr and brr are pointing to the same array in memory, so when you change the value of arr[0], it also changes the value of brr[0].
The text was updated successfully, but these errors were encountered:
In the Lecture 49: Time: 1:00:00
Based on the code you provided, the output should be 1 and not 4. The reason for this is that when you create an array in Java, it creates a new object in memory to store the values in the array. So, when you assign
arr
to{1, 2, 3}
andbrr
to{1, 2, 3}
, you have two separate arrays in memory with the same values.When you change the value of
arr[0]
to 4, it only affects thearr
array and not thebrr
array. Therefore, when you printbrr[0]
, it should still be 1.However, if you had assigned
brr
toarr
like this:then the output would be 4 because both
arr
andbrr
are pointing to the same array in memory, so when you change the value ofarr[0]
, it also changes the value ofbrr[0]
.The text was updated successfully, but these errors were encountered: