Showing posts with label Java Builtin Sorting Function. Show all posts
Showing posts with label Java Builtin Sorting Function. Show all posts

Saturday, 26 July 2014

How to sort integers of array using Java builtin Function

Structure of the Problem Requirements 

Java language facilitate its developers with many builtin function. When we deal with arrays in Java then there are many function 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
Java Sorted Array