Write a Program in JAVA WHICH RETURN THE MAXIMUM NUMBER IN Array

In this problem we will learn how to find the biggest number in array. The program will asked user to enter his number and then give the maximum number as return on his first index of array. A simple IF condition is used for this program which replace the Max number every time whenever array num is bigger then it.

Source Code


package com.ancodingpoints.www;
import java.util.Scanner;

public class Find_Max {

    public static void main (String [] args )
 {
     Scanner input = new Scanner (System.in);
     int num [] = new int [5];
     int max = num[0];
     for ( int i = 0; i < 5; i++)
             {
             System.out.println(" Enter your Number : ");
             num[i] = input.nextInt();
             if (num[i] > max )
             {
                 max = num[i];
             }
     }
     System.out.println(" The Maximum Integer is :" + max);
     }
     }

Output of the Program

    
Java Array Programming



Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment