Java BigDecimal

  • + 3 comments

    Hi. The sort method takes 4 parameters. The first parameter is the array to sort. The next 2 parameters are the range to sort from [0,n] exclusive (includes 0 but not n). The last argument is the customComparator that I wrote to teach it how to sort.

    The customComparator I wrote is a Comparator, and it must override the compare function. Reading the documentation for compare will answer most of your questions If the compare function returns a negative value, then s1 comes before s2. If it returns a positive value, then s2 comes before s1. Based on that information, Arrays.sort can sort arrays.

    HackerRank solutions.