import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class MainClass { public static void main(String[] argv) { Set<String> stringSet = new HashSet<String>(); stringSet.add("aaaa"); stringSet.add("a"); stringSet.add("aa"); stringSet.add("aaa"); float totalLengths = 0f; Iterator<String> iter = stringSet.iterator(); while (iter.hasNext()){ totalLengths += iter.next().length(); } } }