Write a Java Program to find largest number in an array

Write a Java Program to find largest number in an array

Write a Java Program to find largest number in an array

Program
public class Main 
{
    public static void main(String[] args) 
    {
        int[] a = new int[] { 20, 30, 500, 4, 71, 100};
        int max = a[0];
        for(int i = 1; i < a.length;i++)
        { 
            if(a[i] > max)
            {
                max = a[i]; 
            }
        
        }
        System.out.println("The Given Array Elements are:");
        for(int i = 0; i < a.length;i++)
        { 
            System.out.println(a[i]);
        }
        System.out.println("From The Array Element Largest Number is: " + max);
    }
}


Output:

The Given Array Elements are:
20
30
500
4
71
100
From The Array Element Largest Number is: 500



More Questions


37 . Write a java Program to print N prime numbers and find sum and average
38 . Write a Java Program to find largest number in an array
39 . Write a Program to find second largest number in an array
40 . Write a Program to Find largest and smallest number in an array in java
41 . Write a Java Program to find largest and second largest in an array
42 . Write a java program to find the index of the largest number in an array
43 . Write a java program to Find the index of the smallest number in an array
44 . Write a Program to remove duplicate element in an array
45 . Write a java Program to print odd and even numbers from an array
46 . Write a java program to add two matrix
47 . Write a java Program to check given matrix is null matrix



For latest job updates join Telegram Channel: https://t.me/sateeshm

Apply For The Job

Apply For Job

Java Material

Python Material

PLSQL Material

.Net Material

Java Practice Programs

400 Java Programs