“Array Sort Java” Kode Jawaban

array.sort di java

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("\nThe sorted array is: ");
        for (int num : arr) {
            System.out.print(num + " ");
        }
    }
}
Bad Batfish

Java sorting menggunakan 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);

    }
}
SAMER SAEID

Menyortir 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));
    }
}
Tense Turtle

Array Sort Java

import java.util.Arrays;

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

Array Sort Java

import java.util.Arrays;

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

Array Sort Java

import java.util.Arrays;

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

Jawaban yang mirip dengan “Array Sort Java”

Pertanyaan yang mirip dengan “Array Sort Java”

Lebih banyak jawaban terkait untuk “Array Sort Java” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya