java - Strange sorting behavior -
int[] = new int[] {7,2,1,10,8,9}; int[] b = a; arrays.sort(b);
why both arrays sorted after sort-operation on b. shouldn't b sorted?
because 1 array. "a" , "b" references same array.
if utilize clone method re-create values, , b different arrays , b sorted.
java
No comments:
Post a Comment