StringSorting.java Source code

Java tutorial

Introduction

Here is the source code for StringSorting.java

Source

// : c11:StringSorting.java
// Sorting an array of Strings.
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.

import java.util.Arrays;

public class StringSorting {
    public static void main(String[] args) {
        String[] sa = new String[] { "d", "e", "a", "c", "g" };

        System.out.println("Before sorting: " + Arrays.asList(sa));
        Arrays.sort(sa);
        System.out.println("After sorting: " + Arrays.asList(sa));
    }
} ///:~