Java tutorial
//package com.java2s; import java.util.HashSet; public class Main { public static HashSet<String> stringToHashSet(String str) { HashSet<String> hs = new HashSet<String>(); if (str.equals("") || str == null) return null; if (!str.contains(",")) hs.add(str); else { String[] arr = str.split(","); for (String s : arr) hs.add(s); } return hs; } }