“Array.Sort in Java” Kod odpowiedzi

Array.Sort in 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

sortowanie 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

Sortowanie w Javie

// Java Program to sort an elements
// by bringing Arrays into play
 
// Main class
class GFG {
 
    // Main driver method
    public static void main(String[] args)
    {
 
        // Custom input array
        int arr[] = { 4, 3, 2, 1 };
 
        // Outer loop
        for (int i = 0; i < arr.length; i++) {
 
            // Inner nested loop pointing 1 index ahead
            for (int j = i + 1; j < arr.length; j++) {
 
                // Checking elements
                int temp = 0;
                if (arr[j] < arr[i]) {
 
                    // Swapping
                    temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
 
            // Printing sorted array elements
            System.out.print(arr[i] + " ");
        }
    }
}
Aya Jouni

Tablica sort java

import java.util.Arrays;

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

Odpowiedzi podobne do “Array.Sort in Java”

Pytania podobne do “Array.Sort in Java”

Więcej pokrewnych odpowiedzi na “Array.Sort in Java” w Java

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu