Java Code Example: largest number in an array

This program outputs the largest number from an array.

import java.util.Scanner;

public class LargestNumberInArray {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int[] numbers = new int[20];
		int i = 0, currentNumber, quantity;

		System.out.print("How many numbers do you want to store in array? (1 - 20): " );
		quantity = reader.nextInt();

		// Store numbers in array (user input)
		for(i = 0 ; i < quantity ; i++) {
			System.out.println("Please enter a number: ");
			numbers[i] = reader.nextInt();
		}

		reader.close();
		
		currentNumber = numbers[0];

		// loop over array and store largest number in first array position
		for(i = 1; i < quantity; i++) {
			if(currentNumber < numbers[i]) {
				currentNumber = numbers[i];
			}
		}

		System.out.println("Largest number in array is: " + currentNumber);
	}
}
Output
How many numbers do you want to store in array? (1 - 20): 5
Please enter a number: 
1
Please enter a number: 
2
Please enter a number: 
3
Please enter a number: 
4
Please enter a number: 
5
Largest number in array is: 5