Java program to find largest number in array

In this tutorial, Java program to find the largest number in array.
Here is simple algorithm to find larget element in the array.

  • Initialize lrg with arr[0] i.e. first element in the array.
  • If current element is greater than lrg, then set lrg to current element.
import java.util.Scanner;

public class Finder
{
   public static void main(String args[])
   {
       int lrg, size, i;
       int numArr[] = new int[50];
       Scanner scan = new Scanner(System.in);

       System.out.print("Enter Array Size : ");
       size = scan.nextInt();

       System.out.print("Enter Array Elements : ");
       for(i=0; i

Output:

Enter Array Size : 5
Enter Array Elements : 34 85 95 25 75
Searching for the largest Number….

Largest Number = 95

That’s all about Java program to find largest number in array.

[social_share share_on="facebook,twitter,linkedin,whatsapp"][post_navigator in_same_term="true"]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.