
How to sort the numbers in ascending order

import java.util.*;
class SortNumbers{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter List Elements: ");
ArrayList<Integer> list=new ArrayList<Integer>();
for(int i=0;i<5;i++){
int num=input.nextInt();
list.add(num);
}
System.out.println("Numbers in ascending order: ");
Collections.sort(list);
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.