how to sort collection in java
// Use Collections.sort()
import java.util.*;
ArrayList<String> al = new ArrayList<String>();
al.add("teach");
al.add("sleep");
al.add("geek");
Collections.sort(al);//just pass any collection object reference
System.out.println(al);//output :- [geek,sleep,teach]
or
/*
ArrayList<Integer> intal = new ArrayList<Integer>();
al.add(4);
al.add(8);
al.add(2);
Collections.sort(intal);
System.out.println(intal);//output :- [2,4,8]
*/
Also in Java:
- how to make a variable unchangeable in java
- android java retrofit offline cache
- never gonna give you up
- change java version command line debian
- java throws multiple exceptions
- java bigdecimal compareto
- java remove non numbers from string
- java - a program to print open ports
- java return new instance of generic type
- update value of an arraylist java
- java clear bufffer to take next string inpuit
- coding with WDSL spring
- binary number input in int java
- main method java
- how to detect if someone clicks on a jpanel in java
- java if a or b
- how to add element to arraylist
- java 8 loop in map
- basic java coding
- send variable intent
- check if a string is a substring of another string java
- java create inputstream from string
- how to crate a list in java script
- how to use for loop for array in java