Pacific-Design.com

    
Home Index

1. Algorithms

2. Largest Number

Algorithms / Largest Number /

Find Largest Number

public class LargestNumber {

    public static void main(String[] args) {
        int numbers[] = { 14, 76, -5, 15, 8, 33 };

        int largest = numbers[0];
        
        for (int x = 1; x < numbers.length; x++) {
            if (numbers[x] > largest) {
                largest = numbers[x];
            }
        }

        System.out.println("Largest Number is: " + largest );
    }
}