19.6.1 Selection Sort Implementation
Class SelectionSortTest
(Fig. 19.4) contains:
• static
method selectionSort
to sort an int
array using the selection sort algorithm
• static
method swap
to swap the values of two array elements
• static
method printPass
to display the array contents after each pass, and
• main
to test method selectionSort
.
As in the searching examples, main
(lines 57–72) creates an array of int
s named data
and populates it with random int
s in the range 10
–99
. Line 68 tests method selectionSort
.
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.