Comparable isSorted As a final wrap-up to our series of homework problems on sorting we'll write a function to test if a List of Comparables is sorted is ascending order or not. Implement a public non-final class called sorted that provides a single static method issorted. issorted should accept a List of comparables and return true if the list is sorted and false otherwise. If the list is null issorted should return false. Sorted.java

Respuesta :

Answer:

Check the explanation

Explanation:

import java.util.List;

public class Sorted {

   public static boolean isSorted(List<Comparable> arr) {

       for (int i = 1; i < arr.size(); ++i) {

           if (arr.get(i).compareTo(arr.get(i - 1)) <= 0) {

               return false;

           }

       }

       return true;

   }

   

}

ACCESS MORE