Java Reference
In-Depth Information
14 . Can the for loops that perform sorting in the Bubble class shown in Try This 5-1 be
converted into for-each style loops? If not, why not?
No, the for loops in the Bubble class that perform the sort cannot be converted into
for-each style loops. In the case of the outer loop, the current value of its loop
counter is needed by the inner loop. In the case of the inner loop, out-of-order values
must be exchanged, which implies assignments. Assignments to the underlying array
cannot take place when using a for-each style loop.
15 . Can a String control a switch statement?
Beginning with JDK 7, the answer is Yes.
Chapter 6: A Closer Look at Methods and Classes
Search WWH ::




Custom Search