Java program to find largest number in array

Java program to find maximum number in array

Java program to find biggest number in array

Program:-

import java.util.Scanner;
class group{
public static void main(String arng[]){
int value[]= new int[5];
int temp,i;
Scanner data = new Scanner(System.in);
System.out.println("Enter 5 element of array" );
// Enhanced for loop
for(i=0; i < 5; i++ ) value[i] = data.nextInt();
// finding Largest number
temp = value[0];
for(i=0; i < 5; i++ )
{
if(temp > value[i])
continue;
else
temp = value[i];
}
System.out.println("Largest number in array is "+temp);
}
}

Output:-

Enter 5 element of array
25
154
28522
218
2564
Largest number in array is 28522

Output:-

Enter 5 element of array
25
14
58
26
14
Largest number in array is 58


Learn Java:-
Java codes

Java Programs:-
List of Java Programs

5 Comments

  1. can you do it in the other way

    ReplyDelete
  2. can you please do it in the other way

    ReplyDelete
  3. how can we find this code complexsity

    ReplyDelete
  4. explain what is (String arng[]) please..

    ReplyDelete
  5. Thanks for sharing
    http://www.mycodingland.com/2015/11/java-program-to-find-maximum-number.html

    ReplyDelete

Add your comments here

Back to Top