1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Testing in Java

Connected

Exercise

Edge cases: Array maximum

Another common programming exercise is about sorting or finding the maximum value in an array. Here is the simplest version of a it, together with a basic solution. The solution is not entirely correct, as it does not handle a key edge case, an empty array, which will result in an exception.

Run the code to see a RuntimeException triggered.

Instructions

100 XP
  • Click "Run Code" to produce an ArrayIndexOutOfBoundsException and then submit.