This is an example of how call by value is implemented in java . When you do the below example , your original deck is being altered
shuffled.add(deck.remove(c));
// Changes the value of the underlying object of deck reference, hence
// both the original deck and the deck variable in the function are altered
The below statement only changes the reference of the variable in the function. Your original deck object still is an emptied out list
deck = shuffled;
// The deck variable in the function is now pointing to shuffled within
// the function. This deck variable is lost after your function call ends.