anku580 / Java-Algorithms

This repository contains java algorithms and some interview questions.
11 stars 57 forks source link

Sorting.java #3

Closed Amisha-here closed 3 years ago

Amisha-here commented 3 years ago

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);

}

}

Sharkaboi commented 3 years ago

Hey This is the wrong place to post your contribution, head over to Pull requests