title | date | draft | tags | categories | |||
---|---|---|---|---|---|---|---|
算法4 Java解答 1.2.08 |
2019-02-22 07:35:22 +0800 |
false |
|
|
Suppose that a[] and b[] are each integer arrays consisting of millions of inte- gers. What does the follow code do? Is it reasonably efficient? int[] t = a; a = b; b = t;
Answer. It swaps them. It could hardly be more efficient because it does so by copying references, so that it is not necessary to copy millions of elements.