1import java.util.Arrays;
2import java.util.HashSet;
3
4/**
5 * Java Program - Find Unique Words
6 */
7public class Example {
8
9 public static void main(String[] args) {
10
11 String str = "apple banana mango grape lichi mango apple grape";
12
13 String[] words = str.split(" ");
14
15 HashSet<String> uniqueWords = new HashSet<String>(Arrays.asList(words));
16
17 for(String s:uniqueWords)
18 int i=1;
19 System.out.println(i+". "+s);
20 }
21
22}
23