| title | 算法4 Java解答 1.2.08 | ||
|---|---|---|---|
| date | 2019-02-22 07:35:22 +0800 | ||
| draft | false | ||
| tags |
|
||
| categories |
|
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.