The Java Collections Framework (JCF) is a set of classes and interfaces that implement commonly reusable collection data structures. The JCF is part of the Java Standard Library, which provides data structures and algorithms for storing and manipulating groups of objects. It is a unified architecture for representing and manipulating collections, allowing collections to be manipulated independently of the details of their representation.
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class CollectionsExample {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("Banana");
list.add("Apple");
list.add("Orange");
// Sort the list
Collections.sort(list);
// Print the sorted list
for (String fruit : list) {
System.out.println(fruit);
}
}
}
Apple
Banana
Orange