Minimum and Maximum

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

array     = new int[ size ];  

Minimum and Maximum

The largest integer in a list of integers is the maximum value. The maximum may occur several times, but no other integer in the list is larger. Look at the following:

2, 9, 52, 23, -19, 23, 17, -45, 0

The integer 52 is the maximum. If you plot these integers on a number line 52 is the last one on the right:

number line

Similarly, the smallest integer in the list is the minimum. The minimum may occur several times. In the above list, the minimum is -45. The minimum is the last number on the left of the number line.

QUESTION 7:

Examine the following collection of integers:

-20, 19, 1, 27, 5, -1, 27, 19, 5
  1. What is the maximum of the collection?
  2. How did you figure this out?