1// Use Collections.sort()
2import java.util.*;
3ArrayList<String> al = new ArrayList<String>();
4al.add("teach");
5al.add("sleep");
6al.add("geek");
7Collections.sort(al);//just pass any collection object reference
8System.out.println(al);//output :- [geek,sleep,teach]
9
10or
11/*
12ArrayList<Integer> intal = new ArrayList<Integer>();
13al.add(4);
14al.add(8);
15al.add(2);
16Collections.sort(intal);
17System.out.println(intal);//output :- [2,4,8]
18*/