How to sort integers of array using Java builtin Function

Java language facilitate its developers with many builtin functions. When we deal with arrays in Java then there are many functions and array sorting is one of them. This function sort integers in ascending order . You just declare the array class in your package and use this function.

Source Code



package com.ancodingpoint.www;
import java.util.Arrays;
import java.util.Scanner;

public class Arrays_sorting{

 public static void main(String[] args) {

     Scanner input = new Scanner (System.in);
     int numbers[] = new int [5];
     for       (int i=0; i<5; i++)
     {
     
         System.out.println(" Enter Your Number ");
         numbers[i] = input.nextInt();
         
         
}
                System.out.println(" Number After Sorting ");
for (int i=0; i<5;i++)
{
    Arrays.sort(numbers);
    System.out.println(numbers[i]);
}
 }
 }

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