MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.util.Arrays;
import java.util.TreeSet;

public class MainClass {
    public static void main(String args[]) throws Exception {

        String elements[] = { "A", "C", "D", "G", "F" };
        TreeSet set = new TreeSet(Arrays.asList(elements));

        System.out.println(set.tailSet("C"));
        System.out.println(set.headSet("C"));
        System.out.println(set.headSet("C\0"));
        System.out.println(set.tailSet("C\0"));
        System.out.println(set.subSet("C", "F\0"));
        System.out.println(set.subSet("C", "C\0"));
        System.out.println(set.subSet("C", "C"));
    }
}