Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Arrays;

import java.util.HashSet;

import java.util.Set;

public class Main {
    /**
     * Function to remove duplicate elements from the array of string
     * @param stringArray array of string having duplicate elements.
     * @return unique array of string 
     */
    public static String[] removeDuplicatesFrom(String[] stringArray) {
        Set<String> temp = new HashSet<String>(Arrays.asList(stringArray));
        String[] uniqueStringArray = temp.toArray(new String[temp.size()]);
        return uniqueStringArray;
    }
}