How to sort an array in Java ?

If you want to sort an array in Java , you can use the Arrays.sort utility method to do it.

How to sort an array in Java ?

Below is a sample code snippet demonstrating the usage of the Arrays.sort utility method to sort an array in java.

package com.abundantcode;
import java.util.Arrays;
public class Main {

    public static void main(String[] args)
    {
        String[] input = {"Java", "Abundantcode.com", "MCA Lab Programs", "B.E Java Lab Programs", "BCA Java Programs"};
        Arrays.sort(input);
        System.out.println("Sorted Array");
        System.out.println("--------------------------");
        for(String item:input)
            System.out.println(item);

    }
}
image