Displaying the Percentage Difference Between the Sorting Times

Lines 43–44 use a NumberFormat (package java.text) to format the ratio of the sort times as a percentage. NumberFormat static method getPercentInstance returns a NumberFormat that’s used to format a number as a percentage. NumberFormat method format performs the formatting. As you can see in the sample output, the sort method took over 400% more time to sort the 15,000,000 random int values.

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.