Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        String elements[] = { "M", "N", "O", "P", "Q" };
        Set set = new HashSet(Arrays.asList(elements));

        String[] strObj = new String[set.size()];

        strObj = (String[]) set.toArray(strObj);

        for (int i = 0; i < strObj.length; i++) {
            System.out.println(strObj[i]);
        }
        System.out.println(set);
    }
}