Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsSortExample1 { public static void main(String[] args) { //Create an array of string objects String str[] = { "Java","Python","Android","One","Ruby","Node.js"}; //Create list List
list = new ArrayList<>(Arrays.asList(str)); System.out.println("Specified value before sort: "+list); //Sort the list Collections.sort(list); System.out.println("Specified value after sort: "+list); } }
Output