# Find Largest Number in an Array Using Java

The following Java program finds the largest number in a given array. Initially the largest variable value is set as the smallest integer value (Integer.MIN_VALUE) and whenever a bigger number is found in array, it is overwritten with the new value. We iterate through the entire array with the above logic to find the largest number.

## Print the Largest Number in an Array Using Java

```// Java program to find largest number in an array
public class FindLargest {

public static void main(String[] args) {
int[] numbers = {88,33,55,23,64,123};
int largest = Integer.MIN_VALUE;

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

System.out.println("Largest number in array is : " +largest);
}
}```

Do you have a programming problem that you are unable to solve? Please send us your problem and we will publish the solution on this site within 48 hours! Please email us.

### One Response to “Find Largest Number in an Array Using Java”

1. I cannot get my program to run. im trying to find the maximum number from my array where I accept 10 numbers from the keyboard but it’s not working.

Int number [] = {32, 42, 53, 54, 32, 65, 63, 98, 43, 23};
int highest = Integer.MIN_VALUE;
Scanner keyboard = new Scanner(System.in);
System.out.println(“Enter 10 numbers”);
highest = keyboard.nextInt();
numbers = new int [highest]

for(int counter = 0; counter highest);
highest = numbers[counter];
}
System.out.println(“Highest number in array is: ” + highest)
}
}