Advertisement
ZazoTazo

Array Descending Sort

Jul 1st, 2019
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.*;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner input = new Scanner(System.in);
  9.         Integer numbers[];
  10.         System.out.println("Welcome to the sorting program!");
  11.         System.out.print("Enter size of array: ");
  12.         int size = input.nextInt();
  13.         numbers = new Integer[size];
  14.         int number;
  15.         for(int i=0; i < numbers.length; i++){
  16.             System.out.print("Enter number: ");
  17.             number = input.nextInt();
  18.             numbers[i] = number;
  19.         }
  20.         Arrays.sort(numbers, Collections.reverseOrder());
  21.         for(int i=0; i < numbers.length; i++){
  22.             System.out.println(numbers[i]);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement