Here is the code block I am referring:
public class ExtraCandies
{
public static void main(String[] args)
{
int[] candies = {2,3,5,1,3};
int temp = 0;
List<Boolean> isGreatestPossibleList = new ArrayList<>();
int[] tempArray = candies;
Arrays.sort(tempArray);
//Here the debugger shows both tempArray and candies array as sorted.
}
}
When I debug this code, I get that the tempArray gets sorted just fine. And the tempArray becomes {1,2,3,3,5}. But the debugger now also shows the candies array got sorted. I am confused how can this be? Shouldn't the sort method only sort the tempArray here?