Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

public class Main {
    public static void main(String[] args) {
        List<String> fruits = new ArrayList<String>();
        fruits.add("A");
        fruits.add("");
        fruits.add("C");
        fruits.add("D");
        fruits.add("A");

        Collator collator = Collator.getInstance(Locale.US);

        Collections.sort(fruits, collator);

        for (int i = 0; i < fruits.size(); i++) {
            String fruit = fruits.get(i);

            System.out.println("Fruit = " + fruit);
        }
    }
}