Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

sort array java

import java. util. Arrays;
Arrays. sort(array);
Comment

sort method in java array

import java.util.Arrays;
import java.util.Collections;

class ArraySort {
    public static void main(String[] args) {
        Integer[] arr = { 5, 2, 1, 8, 10 };
        Arrays.sort(arr, Collections.reverseOrder());
        
        for (int values : arr) {
            System.out.print(values + ", ");
            // 10, 8, 5, 2, 1,
        }
    }
}
Comment

Array Sort java

import java.util.Arrays;

Arrays.sort(/*Enter the name of the Array*/);
Comment

sorting java

public class SortingData {
    public static void main(String[] args)
    {
        int[] arr = { 13, 7, 6, 45, 21, 9, 101, 102 };
  		
        Arrays.sort(arr);//sort() function
  
        System.out.printf("Modified arr[] : %s",
                          Arrays.toString(arr));
    }
}
Comment

Java Sorting Using sort()

import java.util.ArrayList;
import java.util.Collections;
class Main {
    public static void main(String[] args) {
        // Creating an array list
        ArrayList<Integer> numbers = new ArrayList<>();
        // Add elements
        numbers.add(4);
        numbers.add(2);
        numbers.add(3);
        System.out.println("Unsorted ArrayList: " + numbers);

        // Using the sort() method
        Collections.sort(numbers);
        System.out.println("Sorted ArrayList: " + numbers);

    }
}
Comment

sort method in java array

import java.util.Arrays;
import java.util.Collections;

class ArraySort {
    public static void main(String[] args) {
        Integer[] arr = { 5, 2, 1, 8, 10 };
        Arrays.sort(arr, Collections.reverseOrder());
        
        for (int values : arr) {
            System.out.print(values + ", ");
            // 10, 8, 5, 2, 1,
        }
    }
}
Comment

java program to sort an array

import java.util.Arrays;
  
class GFG {
    public static void main(String args[])
    {
        int[] arr = { 5, -2, 23, 7, 87, -42, 509 };
        System.out.println("The original array is: ");
        for (int num : arr) {
            System.out.print(num + " ");
        }
        Arrays.sort(arr);
        System.out.println("
The sorted array is: ");
        for (int num : arr) {
            System.out.print(num + " ");
        }
    }
}
Comment

Array Sort java

import java.util.Arrays;

Arrays.sort(/*Enter the name of the Array*/);
Comment

Array Sort java

import java.util.Arrays;

Arrays.sort(/*Enter the name of the Array*/);
Comment

java sort method

Arrays.sort();//this method is an inbuild function in java
//to sort the array
Comment

sort java array

import java. util. Arrays;
// int[] arr = {1,7,3,5};
Arrays.sort(myArr);
Comment

java order an array

Arrays.sort();
Comment

PREVIOUS NEXT
Code Example
Java :: Difference between Public, Private and Protected modifier in Java? 
Java :: fill two dimensional array row by row java 
Java :: resize image icon to fit jlabel 
Java :: how to convert int to string in java? 
Java :: open website from android activity 
Java :: How to build a Sudoku solver, in Java? 
Java :: retrofit android 
Java :: jframe color 
Java :: java string array initialization 
Java :: arraylist reverse in java 
Java :: java hash password 
Java :: list of integers in java 
Java :: flutter java.lang.RuntimeException: Unable to instantiate activity ComponentInfo 
Java :: pointers in java 
Java :: java scan a file 
Java :: difference between object and class 
Java :: how generate a random number in java between 3 and 5 
Java :: all installed java 
Java :: android studio change button color programmatically 
Java :: how to find selenium webelement java 
Java :: linear search java 
Java :: java print item to text file 
Java :: method reference in java 
Java :: delete one item from list recycleview 
Java :: how to copy array in java 
Java :: character types java 
Java :: java remove map 
Java :: java instanceof 
Java :: how to use do while loop in java 
Java :: run java from terminal 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =