1. Learn
  2. /
  3. Courses
  4. /
  5. Optimizing Code in Java

Connected

Exercise

Implementing a sort checker application

You're implementing a method to check if an ArrayList of integers is sorted in ascending order. The current implementation compares every possible pair of elements in the list to ensure they are in the correct order.

Instructions

100 XP
  • Iterate through all the numbers in numbers, using i as the iterator and starting at 0.
  • Iterate through all the numbers in numbers again, using j = i + 1, looping through numbers, and incrementing i.
  • Finish the return statement to return true when you have not found a pair in wrong order.