Research breakthrough possible @S-Logix pro@slogix.in

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to find biggest number in java?

Description

This program finds the biggest number in an array of the integer. Array of Integer is sorted using sort method of Arrays class that sorts the elements in natural order (Integer-ascending order). As the sort method is static the input array is modified instead of creating new array. Hence the last element of the array gives the biggest number.

Sample Code
  • Filename: Biggest.java

import java.util.*;
class Biggest {
public static void main(String args[]) {
//Sorting Integer in natural order
int n[] = {40,20,99,65,74};
Arrays.sort(n);
System.out.println("Sorted list of Integer");
for(int i:n) {
System.out.println(i);
}
int l=n.length;
int biggestNumber = n[l-1];
System.out.println("Biggest number="+biggestNumber);
}
}

Screenshots

Find biggest number in java