import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SortExample {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("Banana");
list.add("Apple");
list.add("Orange");
Collections.sort(list);
for (String fruit : list) {
System.out.println(fruit);
}
}
}Java: How to Sort a List
Related Posts
More content you might like
Code
python
Find Maximum Value in a List
No preview available for this content.
Jan 26, 2024
Read More Code
python
Calculate Average of Numbers
No preview available for this content.
Jan 26, 2024
Read More Code
python
Remove Duplicates from a List
No preview available for this content.
Jan 26, 2024
Read MoreDiscussion 0
Please sign in to join the discussion.
No comments yet. Be the first to share your thoughts!